basteln
basteln

Reputation: 2627

Node.js nvm and npm directory structure

today I noticed that I couldn't execute some node.js programs (e.g. weinre) from the shell by typing $ weinre. But I had it installed (two versions even) in ~/.npm/weinre/2.0.0-pre-2012-03-02--15-31-31/package/weinre and in ~/.npm/weinre/2.0.0-pre-H41DGW8S-incubating/package/weinre. To top it off, I also have a ~/local/node_modules/ path, but there's only socket.io. (I'm on a Mac and ~/local/ is in my path, I use it instead of /usr/local/).

So it appears that node modules can be in ~/.nvm/v0.8.1/lib/node_modules, in ~/.npm (with version number and "package" subfolder) and in ~/local/node_modules. So where should they go?

I ran npm install -g weinre which installed an alias to ~/.nvm/v0.8.1/bin/weinre. The alias points to ~/.nvm/v0.8.1/lib/node_modules/weinre/weinre. I still have the other two weinres in the ~/.npm/weinre path written above.

Something seems to be broken here...can someone please explain or help to fix it? :(

Upvotes: 1

Views: 1125

Answers (1)

LJHarb
LJHarb

Reputation: 39454

(nvm maintainer here)

Everything in ~/.npm is npm's cache; you shouldn't be looking in there or concerned with it at all :-)

Your global node modules will be in npm root -g. ~/.nvm/v0.8.1/lib/node_modules is that path for the nvm-managed node version 0.8.1; ~/local/node_modules is probably that path for your system node.

Upvotes: 1

Related Questions