npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Error while installing npm packages on ubuntu 19.04

Nodejs: v12.6.0
Npm: 6.10.1
Ubuntu: 19.04

usama@usama:~/Learn/back-end/advance-nodejs/section two$ sudo npm i webworker-threads

> webworker-threads@0.7.17 install /home/usama/Learn/back-end/advance-nodejs/section two/node_modules/webworker-threads
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/usama/Learn/back-end/advance-nodejs/section two/node_modules/webworker-threads/build'
gyp ERR! System Linux 5.0.0-20-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/usama/Learn/back-end/advance-nodejs/section two/node_modules/webworker-threads
gyp ERR! node -v v12.6.0
gyp ERR! node-gyp -v v5.0.2
gyp ERR! not ok 
npm WARN section-two@1.0.0 No description
npm WARN section-two@1.0.0 No repository field.

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

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/usama/.npm/_logs/2019-07-13T13_12_46_875Z-debug.log

You shouldn’t need to use sudo when installing locally in a project folder. Try this:

sudo chown -R $USER "/home/usama/Learn/back-end/advance-nodejs/section two/"
npm i worker-threads #no sudo