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)

Most upvoted comments

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 then yarn install then gatsby 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 instance nvm use v8.14 installed the gatsby package npm install --global gatsby-cli created a new project and cd’d into the directory gatsby new website cd website did a yarn update and install yarn upgrade --latest yarn install then ran gatsby 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 the package-lock.json file was probably guiding the reinstallation and that hadn’t changed, so I deleted that as well as the node_modules. Running npm i this time worked perfectly.

Never sudo npm anything - source. Use npm 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 my yarn.lock did.

I just had the same issue and I could resolve it by installing sharp first: npm install sharp and then all npm modules npm 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

sharp@0.22.1 install /Users/udittakkar/projects/Rocket.Chat/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Using cached /Users/udittakkar/.npm/_libvips/libvips-8.7.4-darwin-x64.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=14.17.6 runtime=node arch=x64 libc= platform=darwin)
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
  CXX(target) Release/obj.target/sharp/src/metadata.o
  CXX(target) Release/obj.target/sharp/src/stats.o
../src/stats.cc:130:19: error: no matching member function for call to 'Set'
        channels->Set(i, channelStat);
        ~~~~~~~~~~^~~
/Users/udittakkar/.meteor/packages/meteor-tool/.2.3.6.1qoxqnl.3ahk++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/v8.h:3670:37: note: candidate function not viable: requires 3 arguments, but 2 were provided
  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
                                    ^
/Users/udittakkar/.meteor/packages/meteor-tool/.2.3.6.1qoxqnl.3ahk++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/v8.h:3673:37: note: candidate function not viable: requires 3 arguments, but 2 were provided
  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
                                    ^
1 error generated.
make: *** [Release/obj.target/sharp/src/stats.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/udittakkar/.meteor/packages/meteor-tool/.2.3.6.1qoxqnl.3ahk++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 20.6.0
gyp ERR! command "/Users/udittakkar/.meteor/packages/meteor-tool/.2.3.6.1qoxqnl.3ahk++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/bin/node" "/Users/udittakkar/.meteor/packages/meteor-tool/.2.3.6.1qoxqnl.3ahk++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/udittakkar/projects/Rocket.Chat/node_modules/sharp
gyp ERR! node -v v14.17.6
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
npm WARN The package eslint-plugin-import is included as both a dev and production dependency.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.22.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.22.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!     /Users/udittakkar/.npm/_logs/2021-09-13T20_26_58_161Z-debug.log

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!