I try to use googleapis with Meteor Framework, it's based on npm.
i did:
meteor npm i googleapis --save
+ [email protected]
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
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.
God point, didn't thought on that,
it uses
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
babel-runtime upgraded from 1.2.5 to 1.2.7
and now it's working
Most helpful comment
babel-runtime upgraded from 1.2.5 to 1.2.7
and now it's working