node.js - NODE_PATH no effect -


i

~ $ npm install express" 

will not install express in home folder, instead in ~/apps/node_modules.

so inserted export node_path=/home/a/apps/node_modules in .bashrc , did source .bashrc.

unfortunately, npm install express still installs in /home/a/node_modules , npm install -g express require root/administrator.

how possible npm install packages in /home/a/apps/node_modules?

node_path used find modules, not install them.

you can use --prefix signify npm should install package:

npm --prefix ~/apps install express 

you make more permanent configuring npm use prefix, overwrite global location. need use -g flag:

# config once npm config set prefix ~/apps  # after that, '-g' install packages in ~/apps npm install express -g 

also, using -g install packages in ~/apps/lib/node_modules (which, think, cannot changed), add directory $node_path well.

another solution create shell alias npm:

# in ~/.bashrc alias npm="command npm --prefix ~/apps" 

although i'm not entirely sure how work -g.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -