Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Locally-installed modules in node.js

Locally-installed modules in node.js


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:

  1. When should I use global installation of the modules with npm install -g and when to use local installation (especially for express applications)?

  2. 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!

Problem courtesy of: Jeff Jia


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:

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

Solution courtesy of: pfried


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Locally-installed modules in node.js


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription