S.Akrem
S.Akrem

Reputation: 71

Why I can't use npm packages in meteor project?

I need to add a npm package in my meteor project (for example 'moment' package). First I typed this command : meteor npm install --save moment . The package.json dependencies updated (moment package added), also in node_modules. I want to use this package, so I add this line in the client side:

const moment = require('moment');

I get this message in my browser console Uncaught SyntaxError: Unexpected identifier in this line !!

Did I miss something ?

Upvotes: 1

Views: 203

Answers (2)

Henri Beck
Henri Beck

Reputation: 81

You can only use npm packages in meteor 1.3+. For any previous versions, you will need a wrapper package or you can use meteorhacks:npm.

Upvotes: 0

Alex Polkhovsky
Alex Polkhovsky

Reputation: 3360

You need to do meteor npm install meteor-node-stubs --save for this to work. See Using NPM Packages in the guide.

Upvotes: 1

Related Questions