I'm trying to install a node package using NPM, but it just gives a permission error. I could install packages without any issues yesterday, but for some reason it has stopped working.

asgeir@1e19udt0shu6:~/nodejs/first_test_app$ sudo npm install sharp

> [email protected] install /home/asgeir/nodejs/first_test_app/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-linux-x64.tar.gz
ERR! sharp EACCES: permission denied, open '/home/asgeir/nodejs/first_test_app/node_modules/sharp/9016-libvips-8.7.4-linux-x64.tar.gz'
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/asgeir/nodejs/first_test_app/node_modules/sharp/build'
gyp ERR! System Linux 2.6.32-042stab133.2
gyp ERR! command "/usr/local/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/asgeir/nodejs/first_test_app/node_modules/sharp
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN [email protected] No repository field.

npm ERR! errno 1
npm ERR! [email protected] install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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/asgeir/.npm/_logs/2019-07-17T06_16_33_097Z-debug.log

After a bit of googling, I found some fellow pour souls who ran in to the same error. They apparently got it working by re-installing NPM and NodeJS, but I didn't have any success with that. Any ideas on how to get past this error?

1 Answer 1


After another session of extreme googling, I found this solution:

Use this command to force NPM to install the Sharp package.

sudo npm install --unsafe-perm=true --allow-root

Mention the dependency need to download if need to download a specific module.

sudo npm install dependency-name --unsafe-perm=true --allow-root

I'm don't really know Linux etiquette, but this command feels like sinning. It works though!

Edit: If it doesn't work for you, try this post I found on SO.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .