0

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

> sharp@0.22.1 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 first_test_app@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.22.1 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 sharp@0.22.1 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?

0

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.