javascriptnode.jsnpmnpm-installgyp

`npm install npm` gives gyp ERR and npm ERR


Why do I get this strange error when doing sudo npm install npm? I also sometimes get it when trying to install other modules!

Error:

> scrypt@6.0.3 preinstall /home/user/code/project/api_v0.8/node_modules/scrypt
> node node-scrypt-preinstall.js


> scrypt@6.0.3 install /home/user/code/project/api_v0.8/node_modules/scrypt
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/user/code/project/api_v0.8/node_modules/scrypt/build'
gyp ERR! System Linux 4.20.0-042000-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/user/code/project/api_v0.8/node_modules/scrypt
gyp ERR! node -v v9.11.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN api_v0.8@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt@6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the scrypt@6.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

What can I do, to have a clean install of my packages?


Solution

  • To solve this, install node version manager:

    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

    user node v8.15.0:

    nvm install 8.15.0
    nvm use 8.15.0