javascript - Npm install global modules on different location node js - Stack Overflow

I am on a unix os, ubuntu, and I am experiencing a problem in installing global modules.When I tried to

I am on a unix os, ubuntu, and I am experiencing a problem in installing global modules.

When I tried to look up where the node_modules folder is, I found out that npm installed some of my global modules in

/usr/lib/node_modules

and some of them are installed in

/usr/local/lib/node_modules

I have no problem before on using this global modules, until such time I tried installing a generator, that is when I first thought of looking into the directories because, after installing the generator, it says that I haven't installed the generator.

What is odd is that when I tried some of the modules, they work perfectly fine except for the other modules, saying it wasn't installed.

Is there a way to uninstall/remove/clean my puter from nodejs including its module and install it again so that it will just be using a single directory, so there won't be any confusion.

Why do you think npm installed this things in two diff. directories.

I am on a unix os, ubuntu, and I am experiencing a problem in installing global modules.

When I tried to look up where the node_modules folder is, I found out that npm installed some of my global modules in

/usr/lib/node_modules

and some of them are installed in

/usr/local/lib/node_modules

I have no problem before on using this global modules, until such time I tried installing a generator, that is when I first thought of looking into the directories because, after installing the generator, it says that I haven't installed the generator.

What is odd is that when I tried some of the modules, they work perfectly fine except for the other modules, saying it wasn't installed.

Is there a way to uninstall/remove/clean my puter from nodejs including its module and install it again so that it will just be using a single directory, so there won't be any confusion.

Why do you think npm installed this things in two diff. directories.

Share Improve this question asked Nov 22, 2013 at 12:21 Joey HipolitoJoey Hipolito 3,16611 gold badges47 silver badges84 bronze badges 1
  • 1 Possible duplicate of Where does npm install packages? – Liam Commented May 9, 2016 at 16:07
Add a ment  | 

1 Answer 1

Reset to default 3

It looks to me like you have had 2 different versions of nodejs installed. Probably a packaged version and then a new release?

It works because your node folder is probably set to /usr/local/lib/node_modules Node allways traverses the folder tree when looking for modules so if you do a require('imNotHere') it will look in:

/usr/local/lib/node_modules/imNotHere
/usr/local/node_modules/imNotHere
/usr/node_modules/imNotHere
/node_modules/imNotHere

before failing. In your setup modules in /usr/lib/node_modules will still be caught by this

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744892824a4599517.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信