chaonextdoor
chaonextdoor

Reputation: 5129

The directory to use npm to install package

I just get started on nodejs. I have installed nodejs and npm. Now, I want to install some packages like mongodb and express. As my default directory path in cmd is C:\>Users\administrator, do I need to make current folder as nodejs folder to run npm install express/coffee-script or I can just run this command under the default directory path mentioned above?

By the way, I always see the npm install command provided by others starts with a dollar sign, but I can only use the command without the dollar sign. So what does the dollar sign stand for?

Upvotes: 4

Views: 2959

Answers (1)

Pierre
Pierre

Reputation: 6172

By default, npm will run in local mode, and install scripts into ./node_modules. This is great if you need to require your scripts, as you'll do with Express.

Calling it with the -g option installs it globally, wherever node is installed (usually, on Linux, in /usr/local. This is great for packages that are meant to be run using the shell (for example, Supervisor).

Generally, if you want to develop a node.js application under C:\foo\bar\myapp, you will run npm from there.

FYI, the $ sign is a general indication meaning that the following command is meant to be run on the command line.

Upvotes: 7

Related Questions