cyclopse87
cyclopse87

Reputation: 629

Meteor 1.3 import npm module issue

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.

Upvotes: 3

Views: 1175

Answers (1)

kokjinsam
kokjinsam

Reputation: 177

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.

Upvotes: 3

Related Questions