Kosmetika
Kosmetika

Reputation: 21304

n module breaks npm

After I switch from one node.js version to another with n module - https://github.com/visionmedia/n/, my npm is broken...

MacBook-Pro-Dmitri:~ dmitri$ npm --version

module.js:340
    throw err;
          ^
Error: Cannot find module 'npmlog'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at /usr/local/bin/npm:19:11
    at Object.<anonymous> (/usr/local/bin/npm:87:3)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

then i'm installing npm again as it was adviced here - https://github.com/visionmedia/n/issues/101

curl https://npmjs.org/install.sh | sh

npm begins to work..

but then i do another switch for node version:

n 0.8.22

and npm now is broken again with the same error.

it's very annoying.. do I need to install npm manually after every version switch?!

Upvotes: 15

Views: 3067

Answers (5)

Nitin Jadhav
Nitin Jadhav

Reputation: 7306

I had same problem on windows. I uninstalled node, deleted everything from its install directory and re-installed. After restarting command line, I got npm working again.

Upvotes: 0

Derek Hill
Derek Hill

Reputation: 6454

I had the same problem and couldn’t find a solution.

It seems that n is less well maintained than nvm so I completely removed node following these steps and re-installed it using nvm.

(And node now includes npm)

Upvotes: 0

mojoaxel
mojoaxel

Reputation: 1580

You could try installing npmlog manually: npm install -g npmlog

Upvotes: 0

Nick Charney Kaye
Nick Charney Kaye

Reputation: 4340

Are there different global package repositories for different versions?

Perhaps either that package needs to be re-installed globally sudo npm install -g or the package manage cache cleaned sudo npm cache clean after switching version(s).

Upvotes: 1

nilni
nilni

Reputation: 673

Node and npm should get bundled together these days, if you are a frequent version changer like me. You can try installing node with NVM

https://github.com/creationix/nvm

This will help you differentiate packages in different node versions. Just do a npm install after the switch.

PS: The current node version is quite stable right now. You can just use the current version instead of 0.8.22

Upvotes: 0

Related Questions