gatsby: Failed at the sharp@0.21.0 install script. on ubuntu 16.04
Description
I am using"gatsby-plugin-sharp": "^2.0.17",
as well as "gatsby-transformer-sharp": "^2.1.3"
. After installing, it seems that there is an issue installing the sharp dependency.
Steps to reproduce
git clone https://github.com/GatsbyCentral/gatsby-v2-starter-lumen
cd gatsby-v2-starter-lumen
sudo npm install
Expected result
Everything installed properly.
Actual result
> sharp@0.21.1 install /home/dvg/workspace/test/gatsby-v2-starter-lumen/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.0/libvips-8.7.0-linux-x64.tar.gz
ERR! sharp EACCES: permission denied, open '/home/dvg/workspace/test/gatsby-v2-starter-lumen/node_modules/sharp/24782-libvips-8.7.0-linux-x64.tar.gz'
ERR! sharp Please see http://sharp.pixelplumbing.com/page/install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/dvg/workspace/test/gatsby-v2-starter-lumen/node_modules/sharp/build'
gyp ERR! System Linux 4.15.0-43-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/dvg/workspace/test/gatsby-v2-starter-lumen/node_modules/sharp
gyp ERR! node -v v8.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN eslint-config-react-app@3.0.6 requires a peer of babel-eslint@9.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-react-app@3.0.6 requires a peer of eslint@5.x but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.21.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.21.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/dvg/.npm/_logs/2019-01-12T18_22_51_258Z-debug.log
Environment
System:
OS: Linux 4.15 Ubuntu 16.04.5 LTS (Xenial Xerus)
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Shell: 5.1.1 - /usr/bin/zsh
Binaries:
Node: 8.15.0 - /usr/bin/node
npm: 6.5.0 - /usr/bin/npm
Languages:
Python: 2.7.12 - /usr/bin/python
Browsers:
Chrome: 71.0.3578.98
Firefox: 64.0
npmGlobalPackages:
gatsby-cli: 2.4.8
UPDATE:
Before submitting this issue I tried extensively nearly everything, including removing node_modules
and npm install
everything again. It didn’t work.
After waiting a week I tried after @wardpeet suggestion removing node_modules
and npm install
everything again. Now ot works. I have no clue why or what did not work a week ago. Maybe an package update?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 32 (5 by maintainers)
same issue building Gatsby site (Mac M1).
This worked: rm -rf node_modules rm package-lock.json npm install sharp npm install
I managed to resolve this issue. Firstly, CD into your new gatsby project folder and run
yarn upgrade --latest
thenyarn install
thengatsby develop
If that doesn’t work for you, I resolved the issue by installing node 8.14 (I’m not sure if this part is totally necessary, but this is how I got it to work) by doing:
nvm install v8.14
I then switched to that instancenvm use v8.14
installed the gatsby packagenpm install --global gatsby-cli
created a new project and cd’d into the directorygatsby new website
cd website
did a yarn update and installyarn upgrade --latest
yarn install
then rangatsby develop
Let me know if it helped you!
I don’t really like jumping into issues that are marked closed but, given I found this when searching for an answer to my problem, it makes sense to.
I’m on Windows 10, using NodeJS v12.6 and npm 6.9.0, and had sharp failing to work or install. Deleting the
node_modules
directory wasn’t enough - I was still getting errors when trying to install again. Then I realised that thepackage-lock.json
file was probably guiding the reinstallation and that hadn’t changed, so I deleted that as well as thenode_modules
. Runningnpm i
this time worked perfectly.Never
sudo npm
anything - source. Usenpm install --unsafe-perm=true
None of the suggestions above worked for me (yarn, OS X, node 12.9.1) except for downgrading to Node 10, cleaning the yarn cache, rmving node_modules, running yarn install
Annoying having to downgrade my node version for some image processing functionality I don’t even use, but better than nothing I guess.
The same for me, W10 and NodeJS v12.6.0, yarn gave the sharp error (with my repo, cloned in a new computer)
I’ve gone to NodeJS v10.16.0 and yarn has succeeded, and everything works
Same here @IrregularShed, I picked up a Gatsby site I hadn’t touched for a while and ran into the issue.
Removing
node_modules
alone didn’t fix it, but deleting myyarn.lock
did.I just had the same issue and I could resolve it by installing sharp first:
npm install sharp
and then all npm modulesnpm install
That it does it installs the newer version of sharp and it seems to solving the problem.
Getting the exact same
@rickschmoo Tried all this in Mac M1
you should download the libvips tar package manually, then put it into a folder named “_libvips” which you should found it in global cache folder. Then you can try another install ,and it works!