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 > firstname.lastname@example.org 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@example.com No repository field. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! firstname.lastname@example.org 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@example.com 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?