Sharp: Linux Error installing sharp

Created on 26 Mar 2019  路  9Comments  路  Source: lovell/sharp

I have been working on development on the mac and it seems to be working fine so I thought on deployment things could be just fine since the docs are pretty much similar for installation.

Unfortunately, I am getting the following error log:

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/ricardo/_app/node_modules/sharp/9986-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/ricardo/_app/node_modules/sharp/build'
gyp ERR! System Linux 4.4.0-127-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/ricardo/_app/node_modules/sharp
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.
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"})

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.

is the building mainly failing because of the Linux version no being drawing or something else is happening here?

I am currently using Ubuntu 16.04 and I tried installing using sudo npm install --save sharp I also tried using npm install --build-from-source

question

Most helpful comment

Strange thing is that the user I tried the install has is not the root user but it has sudo privileges and would install about anything without any problem also I tried using the service terminal and it had the same issue.

At the end your solution worked using npm install --unsafe-perm I am not sure about this flag capability I could not find it as a reference on npm but thanks for all

All 9 comments

The salient part of this error is:

ERR! sharp EACCES: permission denied, open '/home/ricardo/_app/node_modules/sharp/9986-libvips-8.7.4-linux-x64.tar.gz'

You'll need to ensure whatever user is running npm install has the relevant filesystem permissions. Avoid using sudo/root if possible. If you have to, pass the npm install --unsafe-perm flag.

Strange thing is that the user I tried the install has is not the root user but it has sudo privileges and would install about anything without any problem also I tried using the service terminal and it had the same issue.

At the end your solution worked using npm install --unsafe-perm I am not sure about this flag capability I could not find it as a reference on npm but thanks for all

Sorry but I thought things were fine but they are not...

I managed to install sharp and I tried running it with my pipe scripts but its not working so I tried installing everything again to make sure the installation was correct but I get a different warning now about libvips

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

info sharp Using cached /home/ricardo/.npm/_libvips/libvips-8.7.4-linux-x64.tar.gz
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.
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"})

correct if I am wrong but it says in the docs: libvips and its dependencies are fetched and stored within node_modules/sharp/vendor during npm install

I am not understanding where this libvips should live, globally or within the app module folder in the sharp directory, nevertheless, none of these attempts worked so far.

and whats these peer dependencies?

The warnings are unrelated to sharp and probably come from other dependencies. Run npm ls ajv-keywords etc. to discover more about these.

Please can you provide more details about what "but its not working" means. For example, are there any error messages?

Hi Lovell, before sharp was added to my package file things were installing just fine that鈥檚 why I thought the errors were coming from the sharp bundler installation on my Ubuntu server, after all the struggle getting it to work I cleared all the server and started from scratch and it worked just fine no need to use sudo or unsafe flag for install and sharp is now working.

Performance is better than I expected too 馃憦馃徎

Thank you so much @EFXPROMedia, if it wasnt because of you i didnt finish my app ;) you saved my life ;)

metoo I had to run sudo npm install -g --unsafe-perm sharp and after sudo npm install -g --unsafe-perm cordova-res

Seems the problem is related to the sharp setup picking the wrong user, because I get prompted for a password for 'nobody' (even if I su-do it). Key was --unsafe-perm although I admit I didn't read up on what that does.

I recommend avoiding the use of sudo/root when installing via npm, but if you do, npm's --unsafe-perm flag is required, as is the case for all native modules and not just sharp.

Was this page helpful?
0 / 5 - 0 ratings