Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue while using import { google } from 'googleapis' in Meteor Application #1316

Closed
nanu-c opened this issue Sep 4, 2018 · 3 comments
Closed
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@nanu-c
Copy link

nanu-c commented Sep 4, 2018

I try to use googleapis with Meteor Framework, it's based on npm.
i did:

 meteor npm i googleapis --save
+ googleapis@33.0.0
added 27 packages from 43 contributors in 8.55s

and then on the server

import {google} from 'googleapis';
import fs from 'fs';
Meteor.methods({
getAnalyticsReports: function() {
 console.log("google",google);
 console.log("fs",fs);
});

this results in

I20180904-12:17:30.744(2)? google undefined
I20180904-12:17:30.748(2)? fs { constants: 
I20180904-12:17:30.749(2)?    { O_RDONLY: 0,
I20180904-12:17:30.749(2)?      O_WRONLY: 1,
[...]

or other example

	getAnalyticsReports: function() {
		const analyticsreporting = google.analyticsreporting({
		  version: 'v4',
		  auth: google.auth.oAuth2Client
		});
	}

gives
Exception while invoking method 'getAnalyticsReports' TypeError: Cannot read property 'analyticsreporting' of undefined

Unfortunately it finds the module because of the absence of an error like this
import {google} from 'googleapis2';

Unable to resolve some modules:

  "googleapis2" in [...]/server/main.js (os.linux.x86_64)
                                              
If you notice problems related to these missing modules, consider running:
                                              
  meteor npm install --save googleapis2  

and
import * as test from 'googleapis';

	getAnalyticsReports: function() {
		console.log(test);
	}

I20180904-12:27:31.624(2)? { default: {}, [Symbol(__esModule)]: true }

Any help is apreciated

@JustinBeckwith JustinBeckwith added the type: question Request for information or clarification. Not an issue. label Sep 4, 2018
@JustinBeckwith
Copy link
Contributor

Hello there! Forgive me, but I'm not terribly familiar with meteor. Is it running some kind of babel transformation? I noticed that you're using the import es module syntax for requiring modules, but that would need to be transpiled.

@nanu-c
Copy link
Author

nanu-c commented Sep 4, 2018

God point, didn't thought on that,
it uses

babel-compiler@7.1.1
babel-runtime@1.2.5
ecmascript@0.11.1
ecmascript-runtime@0.7.0
ecmascript-runtime-client@0.7.2
ecmascript-runtime-server@0.7.1

@nanu-c
Copy link
Author

nanu-c commented Sep 4, 2018

babel-runtime upgraded from 1.2.5 to 1.2.7
and now it's working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants