最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin5浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论