What is difference between "meteor npm install" and "meteor add"?

What is difference between the following commands that adds angular-material functionality to project? What command is better to use on production?

  1. meteor npm install angular-material --save
  2. meteor add angular:angular-material

The former is installing npm packages, which will be listed in packages.json and located in the node modules directory and need to be imported into your code.
The latter is using atmosphere packages which will be listed under .meteor/packages and will be included in your build (no need to import).

But why official Meteor Tutorials suggests to use former “meteor npm install” instead of latter “meteor add”? e.g.

https://www.meteor.com/tutorials/angular/templates
meteor npm install --save angular angular-meteor

http://www.angular-meteor.com/tutorials/socially/angular1/angular-material-and-custom-angular-auth-forms
meteor npm install angular-material --save

Above answer is correct, although if you’re using the new directory structure for Meteor 1.3 and placing your files in the ‘imports’ directory you still need to import atmosphere packages in your files that use it. So if you’re using ‘Meteor.accounts’ for example, you need to import meteor.

Because the best practice is to use npm and not Meteor specific package manager (unless it’s for build and then you have to use Atmosphere)

Hi Urigo. I had a couple of more questions: what do you mean by ‘for build’? And is it okay to use yarn instead of npm? Thanks

“For build” is referring to Meteor build plugins, which are primarily used for preprocessors - less, sass, typescript, coffescript, etc. They run when your app is being built instead of being part of your app and currently can’t be hosted on npm.

Meteor now supports using meteor yarn instead of meteor npm. First you have to do meteor npm i -g yarn, and you have to not be running on Windows. :cry:

2 Likes

I have the great misfortune of running on Windows, is there still no hope for me to use meteor yarn?

@asgold8 if you install yarn with meteor’s npm:

meteor npm install -g yarn

You can use meteor yarn

Note that this installs it for a specific meteor version (because each version bundles a specific node and npm version), so you will need to re-install yarn on a meteor update

$ meteor npm install -g yarn
...
updated 1 package in 0.99s
$ meteor yarn
'yarn' is not a Meteor command. See 'meteor --help'.

When I do this on Ubuntu, it works fine, but for Windows 10, it doesn’t work, and I can’t seem to find a solution to this.

oh weird, I thought that’d been fixed since the last post. Sorry

The other option is to make sure the version of Node installed on your system is the same, then use yarn normally.
The issues from using system npm are about building modules for the right node version, so if they match, you can use system wide tools without issue