Moon
Moon

Reputation: 22605

node npm local install puts files into ~/node_modules

When I install a package using npm install command, it installs the files into ~/node_modules. When I run the package, I get command not found error.

How do I install it into a folder where I want to call the package?

Upvotes: 1

Views: 2234

Answers (2)

henry74
henry74

Reputation: 1043

If you don't want to install it globally, the right answer is the last comment in the checked answer:

Simply add ./node_modules/.bin to your PATH, and all the commands installed locally by npm will be available. – H_I Dec 24 '12 at 9:54

You can add it to your path in your .bashrc file using the command: export PATH="$PATH:/home/login/node_modules/.bin"

Reload your .bashrc using: source .bashrc

Upvotes: 1

EhevuTov
EhevuTov

Reputation: 20463

npm install <name_of_package> -g

This will install the package globally. If the program is in your PATH, then you should be able to run it just like any other program.

For example: npm install nodemon -g

then run nodemon from the command prompt, and it should work

Upvotes: 4

Related Questions