Friday, April 14, 2017

npm - set project specific default prefix/path

Leave a Comment

I would like npm ... to always run in the context of a subfolder of my project: "./assets".

When I run this command from the project root, it behaves as expected:

$ npm --prefix ./assets install 

However, it does not read this from the .npmrc in the root folder.

$ echo "prefix=./assets" > .npmrc $ npm i # creates an empty ./node_modules folder 

How can I set a set project specific default prefix for npm commands?

1 Answers

Answers 1

If you have install npm globally you can simply configure prefix to set for specific folder so that you can install other node modules to that folder. Following is the command to set prefix.

npm config set prefix /Programming/node-v0.10.31-linux-x64/

here i have configure Node in node-v0.10.31-linux-x64 this folder and node modules will be install there.

or

if you want to install node modules for specific folder individually you can user following command

npm install bower -g --prefix /Programming/node-v0.10.31-linux-x64/

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment