'Can't install Sharp
When running sudo npm i sharp --save
I get the following errors:
> sharp@0.21.3 install /home/server/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
info sharp Using cached /home/ronny/.npm/_libvips/libvips-8.7.0-linux-x64.tar.gz
ERR! sharp EACCES: permission denied, mkdir '/home/server/node_modules/sharp/vendor'
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/server/node_modules/sharp/build'
gyp ERR! System Linux 4.18.0-13-generic
gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/server/node_modules/sharp
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN server@1.0.0 No description
npm WARN server@1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.21.3 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.21.3 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/ronny/.npm/_logs/2019-01-28T20_33_46_476Z-debug.log
I have the same project running on another machine, and there, the install works flawlessly. But on my other machine (both run Linux Ubuntu) I am facing the above error.
I couldn't find any solution for this error. That's why I am asking for help here.
Solution 1:[1]
this worked for me.
npm install --unsafe-perm
please refer to the following discussion https://github.com/lovell/sharp/issues/1627#issuecomment-477109851
Solution 2:[2]
The simplest way is:
brew uninstall vips
And then:
npm install
Solution 3:[3]
The problem with Node v13.14.0+, the problem will be solved
npm install sharp@0.23.2
You should downgrade Node version to >=10.0.0 if you are using sharp 0.22.1
Solution 4:[4]
For Apple M1 brew install vips
then npm install --unsafe-perm
If it does not solved your problem find more in this similar issue
- xcode-select --install
- brew install gcc
- brew reinstall vips
- brew info vips
- npm i
Solution 5:[5]
I have solved this error by downgrading node version to 10.0.0
. It really works!
Solution 6:[6]
delete package-lock.json and node_modules
then try to install packages npm install
Worked for me.
Solution 7:[7]
npm install --arch=x64 --platform=linux sharp
worked for me
taken from : https://github.com/lovell/sharp/issues/2128#issuecomment-600232917
I am using a M1 mac
Solution 8:[8]
So first the error says Permission denied.
install it using sudo
when you use sudo
in the sharp documentation! it says that you have to use npm install --unsafe-perm
I would recommend:
- go to
/home/ronny/.npm/_libvips/libvips-8.7.0-linux-x64.tar.gz
(in your error code) - remove the file:
libvips-8.7.0-linux-x64.tar.gz
- in your terminal type:
npm install --unsafe-perm
(this will install the deleted lib) npm install sharp
Then I think I should work fine. These steps fixed my issue, I had the same issue. Hope it helps. Thanks.
Solution 9:[9]
Try yarn instead of npm, it works for me (docker, official node image 16.x)
yarn add sharp
Solution 10:[10]
I had the same problem for my Apple M1 and I ran the next comands:
- I removed node_modules
- I deleted package-lock.json
- Run:
brew install vips
- Run:
npm install --unsafe-perm
And it works
Solution 11:[11]
Late but I'm telling you what worked for me. If you have previously installed any dependency that works exactly the same as sharp, remove that dependency
from your Package.json
file and then run
npm install sharp
Solution 12:[12]
Running npx create-strapi-app my-project --quickstart on windows and got the same error, had to install C++ for desktop development from visual studio and it worked.
Solution 13:[13]
In my case, I had to install Python first. After that, it went well. Install Python here.
npm i sharp
npm ERR! code 1
npm ERR! gyp ERR! find Python
gyp ERR! stack at PythonFinder
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow