What are you trying to achieve?
Install sharp and subsequently other node modules.
Have you searched for similar questions?
Unable to find a solution
Are you able to provide a standalone code sample that demonstrates this question?
Are you able to provide a sample image that helps explain the question?
Unfortunately no
The problem
When I npm install sharp, I get the following output:
[email protected] install /projects/user-portal/node_modules/sharp
node-gyp rebuild
make ✖ ERR Missing Makefile / Bakefile
make ℹ info Run "make init" to generate a Makefile.
There seems to be some kind of error but installation still passes. I have run make init but that made no difference for what I write below.
Then when I run other scripts I get the error:
Error: Cannot find module '../build/Release/sharp.node'
And although there has been a folder created called /node_modules/sharp/build, and there is content, it does not include a subfolder called Release.
Googling teaches me “Missing Makefile / Bakefile” has to do with the node module “make”. But how to solve this?
I've also tried running sudo npm install sharp, which results in:
[email protected] install /projects/user-portal/node_modules/sharp
node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/projects/user-portal/node_modules/sharp/build'
gyp ERR! System Linux 3.10.0-957.21.3.el7.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /projects/user-portal/node_modules/sharp
gyp ERR! node -v v8.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN [email protected] requires a peer of knex@>=0.6.10 <=0.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected] - 3 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of popper.js@^1.14.7 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] license should be a valid SPDX license expression
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
Please can you try with the latest v0.22.1.
Sorry, I wasn't using the latest version in the first place. I updated package.json and now npm install sharp results in:
Unhandled rejection Error: EACCES: permission denied, open '/home/user/.npm/_cacache/index-v5/ff/ec/1ac73f831b4be306687ec3ade736ad1a5c148745371b34e6945e71c98510'
Unhandled rejection Error: EACCES: permission denied, open '/home/user/.npm/_cacache/index-v5/63/c8/28772eeccc799c7e548d1a0d34a2fc0607ee0ebb70072c0a17b47e1a8ef6'
npm ERR! cb() never called!
And sudo npm install sharp results in:
> [email protected] install /projects/user-portal/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 '/projects/user-portal/node_modules/sharp/830-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 '/projects/user-portal/node_modules/sharp/build'
gyp ERR! System Linux 3.10.0-957.21.3.el7.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /projects/user-portal/node_modules/sharp
gyp ERR! node -v v8.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN [email protected] license should be a valid SPDX license expression
npm ERR! code ELIFECYCLE
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.
Avoid using sudo with npm install where possible. If you absolutely have to use sudo then add the npm install --unsafe-perm flag.
Got I solved as follows (as per instructions here):
sudo apt remove nodejs npm to remove Node and npmsudo rm -rf to delete node_modules folder and npm foldersudo apt-get install nodejs to install again Node and npmnpm install sharp works again.Avoid using sudo with
npm installwhere possible. If you absolutely have to use sudo then add thenpm install --unsafe-permflag.
This was the only way I could install 'shapr'
Error: EROFS: read-only file system, mkdir '/user' any ideas ?
Most helpful comment
Avoid using sudo with
npm installwhere possible. If you absolutely have to use sudo then add thenpm install --unsafe-permflag.