This seems simple enough but can't seem work it out following the guide for using npm using Npm packages Meteor 1.3 I meteor install the moment npm module.
Then when i try to use the package in the client I keep getting.
import moment from 'moment';
var Moment = require('moment')()
Template.myTemp.events({
'click #exampleBtn': function(e){
e.preventdefault()
console.log(Moment)
}
});
In the console I seem to be getting SyntaxError: import declarations may only appear at top level of a module. ReferenceError: moment is not defined.
You already import moment from 'moment'
, you don't need line #2. Essentially, line #1 and line #2 are the same.
Line #1 is ES2015 module syntax. Line #2 is CommonJS module syntax.
Hope that helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.