Different Express JS Installations

I am just getting started with Express Js. Can someone explain the difference between

npm install

and

npm install -g express

(Installation code taken from enter link description here

The -g flag means install Express in your global node_modules directory. This enables you to call the express command anywhere. npm install express would be used to install the express library in your app, that is, you would navigate to your app directory and type npm install express.

I recommend that you do the following:

npm install -g express

Then when you navigate to your app directory, you'd type npm link express. This symlinks to the global express install.

Does this help?

npm install express

will create a folder called node_modules in your current folder and install express in it.

npm install -g express

will install express on you system in some place like /usr/local/lib/node_modules

The reason why you want a global install of Express or supervisor for example, is to use the bin tool.

The bin tool of express generate a template project which is super useful.

In addition to what @JP Richardson and @3on indicated regarding npm install express and npm -g install express, when you run npm install (without express or -g express) npm will read the package.json file in the current directory and install (locally) the dependencies listed in package.json

This is the reason the example in http://expressjs.com/guide.html works. The package.json that it asks you to create, indicates Express 3.x as a dependency and npm will know how to download it and install it.