15

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?!

sergej shafarenka
  • 20,071
  • 7
  • 67
  • 86
Kosmetika
  • 20,774
  • 37
  • 108
  • 172
  • Visit http://stackoverflow.com/questions/9755841/how-can-i-change-the-version-of-npm-using-nvm This may help you – Ashwin Hegde May 29 '13 at 08:54
  • Also have a look on following links: http://www.backdrifter.com/2011/02/18/using-nvm-and-npm-to-manage-node-js/ http://stackoverflow.com/questions/9133784/node-version-manager-nvm-npm-installing-modules-to-common-folder – Ashwin Hegde May 29 '13 at 08:55
  • What is operating system windows or ubunto? There is windows installer – Prathibha Chiranthana Aug 14 '14 at 04:16

5 Answers5

1

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).

Charney Kaye
  • 3,667
  • 6
  • 41
  • 54
0

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

nilveryboring
  • 653
  • 1
  • 9
  • 18
0

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

mojoaxel
  • 1,440
  • 1
  • 14
  • 19
0

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)

Community
  • 1
  • 1
Derek Hill
  • 5,965
  • 5
  • 55
  • 74
0

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.

Nitin Jadhav
  • 6,495
  • 1
  • 46
  • 48