Locally-installed modules in node.js
Problem
I am a beginner of node.js and express. I find that I can use "package.json" and npm install
to solve the dependency of node.js modules. The command will install locally the
required modules, which seem like static libraries in C++ to me.
I have two questions:
When should I use global installation of the modules with
npm install -g
and when to use local installation (especially for express applications)?I use git for version control. Should I add the locally installed third-party node.js modules to the repository? The modules seem big in size and certainly not my code. I am confused of the version control of those modules.
Any help or hint is welcomed, and thanks in advance!
Solution
1: Install modules you use from the command line globally like expresss, the others locally. If you dont know install them in both places
More info: http://blog.Nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/
2: Dont upload the dependencies to git, you can specify a concrete version number in your package.json file so you dont need them there. Add node-modules
to .gitignore
Discussion
View additional discussion.