Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

node.js - Need to install npm 2.15.5

I upgraded to a higher version of npm But now I can't use nvm use 4.4.6

(Which is what I need for this project and cannot be updated), I get:

/Users/adrq/.nvm/versions/node/v4.4.6/lib/node_modules/npm/bin/npm-cli.js:87
      let notifier = require('update-notifier')({pkg})
      ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v4.4.6` to unset it.

I've tried running nvm use --delete-prefix v4.4.6

But get the same error

I've read about removing the prefix entirely from the npmrc file

But have no idea how, another option would be to see if I can roll back to the previous version of npm. I've tried npm install -g 2.15.5, but get

npm ERR! code E404
npm ERR! 404 Not Found: 2.15.5@latest

Have tried npm install -g 2 and get

+ [email protected]
added 53 packages in 19.338s

however running npm -v returns

5.5.1

Any input is appreciated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Meant to post this days ago;

Here's what I learned

When you use nvm it loads the version of node as well as the best version of npm to use.

So, when I was using v4.4.6 and did an npm install -g npm, this must have messed this up

I needed to reinstall npm within the node version folder

cd ~/.nvm/versions/node/v4.4.6/lib

And then

npm install [email protected]

All works fine now


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...