Meteor and the `npm global repository`


#1

I believe I have been confused about when to use meteor npm v. npm directly. I think the answer is for all things Meteor you need to only use meteor npm, is that correct? Is there something introductory about meteor and npm? I have read the guide many times, but it does not seem to have a discussion of how to think about the global meteor npm repositories.

How should I think about the global meteor npm stuff? Here is how I am beginning to think about it:

Meteor -g repository v. node -g repository

Meteor has a global repository of tools that it keeps for building the app, on windows I see this global repository of node_modules when I execute:

meteor npm list -g

I get a list of node_modules that are installed here: C:\Users\<username>\AppData\Local\.meteor\packages\meteor-tool\1.4.0\mt-os.windows.x86_32\dev_bundle\lib\node_modules. To add packages to this repository I should run meteor npm install <package_name> -g

npm keeps their own repository and on windows I can find it here: C:\Users\<username>\AppData\Roaming\nvm\v4.4.7 C:\Program Files\nodejs

In essence for any tool required of meteor I only install to the meteor repository, I never use the tools from the npm repository. correct?

Meteor app repository

The app repository is simply in the node_modules directory at the root of my project.

Adding an npm package requires using meteor npm install <packagename>. This is well documented in the guide.

Feedback appreciated

Let me know if I have this improperly interpretted.


Error while updating to Meteor 1.4
#2

The concept of meteor npm install -g-ing is fairly new (as in previously we didn’t consider it something that you might actually do).

The aim is that the dev bundle (which is like a pre-installed set of global modules) would have whatever you need to use Meteor., so you shouldn’t need to do it, but there are situation where you might do it, like when running selftests.


#3

Thanks @tmeasday!

OK, now I have a specific question. In #7437, @benjamn pointed me to node-gyp setup instructions for my meteor 1.3.5.1 installation. I just followed the instructions verbatim. Which meant that I simply installed node-gyp in my node global repository.

Was I supposed to have done meteor npm install -g node-gyp?

Will meteor build fail over to the node repository if the tool cannot be found in the dev_bundle? Does meteor have any interactions with the node repository?

Meteor v1.4 already has node-gyp installed so not necessary to do. But I do have to make sure the dev tools are in place so it can compile…

Thanks for any insights.


#4

I think Ben was saying in a generic “if you want to install binary npm packages, you may want node-gyp installed” kind of way, rather than something specific for Meteor’s npm integration.


#5

OK, so installing to the node global repository was the right thing to do? When Meteor requests a compile it would eventually reference the version I had installed to the node global repository?

But now that it ships in the meteor dev_bundle it would be redundant to put a copy in the node global repository?


#6

to: @tmeasday, @abernix, @benjamn

2 open questions re: node-gyp install:

  1. The instructions for pre-requisites include this command
npm install --global --production windows-build-tools

should this command be executed against the dev_bundle? e.g.

meteor npm install --global --production windows-build-tools

And is this a modification to the dev_bundle?

  1. I followed the instructions as written:
npm install -g node-gyp

And I already had the pre-requisites installed. And my build works. How can this work?
does Meteor fail over to the global node tools if they fail in the dev_bundle?

These basic questions are causing confusion over here.

Thanks for any insights.


#7

The dev bundle includes node-gyp already so there’s no need to install it for meteor to pick it up.

However if you were going to run npm install some-binary-package (rather than meteor npm install), for instance in a non-meteor app, it would be useful to have the globally installed (system-wide) node-gyp too.

As for installing windows-build-tools into the dev bundle (via meteor npm install -g), that seems like an interesting idea, and one that we are following up on doing automatically for windows users