gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

Failed at the sharp@0.21.0 install script. on ubuntu 16.04 #11026

Closed daniel-vera-g closed 5 years ago

daniel-vera-g commented 5 years ago

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?

machieajones commented 5 years ago

Getting the exact same

schabluk commented 5 years ago

Getting the same when doploying with Now:

01/13 12:26 PM (2m)
npm ERR! 
01/13 12:26 PM (2m)
code ELIFECYCLE
01/13 12:26 PM (2m)
npm
01/13 12:26 PM (2m)
 ERR! errno 1
01/13 12:26 PM (2m)
npm ERR!
01/13 12:26 PM (2m)
 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
01/13 12:26 PM (2m)
npm ERR! 
01/13 12:26 PM (2m)
npm ERR! Failed at the sharp@0.21.1 install script.
npm
01/13 12:26 PM (2m)
 ERR! This is probably not a problem with npm. There is likely additional logging output above.
01/13 12:26 PM (2m)

01/13 12:26 PM (2m)
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/.npm/_logs/2019-01-13T11_26_07_178Z-debug.log
01/13 12:26 PM (2m)
Error: Exited with 1
    at ChildProcess.child.on (/tmp/utils/node_modules/@now/build-utils/fs/run-user-scripts.js:11:16)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
01/13 12:26 PM (2m)
patching https://api-bru1.zeit.co/v2/now/deployments/dpl_HZht3e8cq2R6y9g9sfMA2k1TSNvb/builds/bld_d6h4vyl1x with {"readyState":"ERROR","errorCode":"BUILD_FAILED_2"}
j10sanders commented 5 years ago

Getting the same, ubuntu 18.10

error An unexpected error occurred: "EACCES: permission denied, unlink '/home/jonathan/git/jonsjournal/node_modules/gatsby-plugin-sharp/node_modules/fs-extra/CHANGELOG.md'".

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

j10sanders commented 5 years ago

I was able to install on another machine with the same OS. Any idea what I might be missing on the machine that doesn't work?

Dogtiti commented 5 years ago

same issue

wardpeet commented 5 years ago

What version of sharp is installed? npm list --pattern sharp

There are probably 2 issues here EACCESS error:

EACCESS is mostly caused by wrong permissions on a folder or bad node installation. you could try to remove node_modules and try npm install all over again, if it doesn't work try sudo npm install.

You could also try the following: (only applies to WSL, osx or linux)

Reinstall npm with a node version manager§ This is the best way to avoid permissions issues. To reinstall npm with a node version manager, follow the steps in “Downloading and installing Node.js and npm”. You do not need to remove your current version of npm or Node.js before installing a node version manager.

now.sh:

Getting the same when doploying with Now:

It could be that now.sh doesn't allow installation of sharp. You might want to have a look at http://sharp.pixelplumbing.com/en/stable/install/#libvips

alexsinfarosa commented 5 years ago

The issue in my case seemed to be related to npm. I have reinstalled node and npm and everything works fine.

daniel-vera-g commented 5 years ago

I was able to install on another machine with the same OS. Any idea what I might be missing on the machine that doesn't work?

Same with me. Installed it on a VM and it works there. But on my machine not.


UPDATE:

Now it seems to work. After @wardpeet suggestion. I have no idea why.

daniel-vera-g commented 5 years ago

What version of sharp is installed? npm list --pattern sharp

There are probably 2 issues here EACCESS error:

EACCESS is mostly caused by wrong permissions on a folder or bad node installation. you could try to remove node_modules and try npm install all over again, if it doesn't work try sudo npm install.

You could also try the following: (only applies to WSL, osx or linux)

Reinstall npm with a node version manager§ This is the best way to avoid permissions issues. To reinstall npm with a node version manager, follow the steps in “Downloading and installing Node.js and npm”. You do not need to remove your current version of npm or Node.js before installing a node version manager.

now.sh:

Getting the same when doploying with Now:

It could be that now.sh doesn't allow installation of sharp. You might want to have a look at http://sharp.pixelplumbing.com/en/stable/install/#libvips

Thanks for your reply. Removing node_modules and doing npm install made it work again.

Nevertheless I tried the same extensively before submitting this issue and it did not work back then. Strange. Maybe someone fixed something in some package.

j10sanders commented 5 years ago

I did all the steps outlined here. Reinstalled node, messed with permissions, deleted node_modules and package.json. I wasn't able to get it working until I finally deleted the project and re-cloned it from github. works now :)

daniel-vera-g commented 5 years ago

I did all the steps outlined here. Reinstalled node, messed with permissions, deleted node_modules and package.json. I wasn't able to get it working until I finally deleted the project and re-cloned it from github. works now :)

There was something strange. Did the same a week ago. It did not work. Yesterday I only deleted the node_modules folder and reinstalled them and it just worked.

machieajones commented 5 years ago

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!

gatsbot[bot] commented 5 years ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

Thanks for being a part of the Gatsby community! 💪💜

gatsbot[bot] commented 5 years ago

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

Thanks again for being part of the Gatsby community!

davelovemartin commented 5 years ago

Never sudo npm anything - source. Use npm install --unsafe-perm=true

dineufeld commented 5 years ago

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.

kuworking commented 5 years ago

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

zilahir commented 5 years ago

@kuworking is right. it's not working with v 12.6.0, only with 10.16.0.

IrregularShed commented 5 years ago

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.

robinmetral commented 5 years ago

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.

IrregularShed commented 5 years ago

@robinmetral Great, I'll give that a go when I get a chance

gotofritz commented 5 years ago

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.

Bechrissed commented 4 years ago

Same here, I have to set Node to 10.17.0 in Gitlab CI pipeline otherwise I can't build.... :(

Oshibuki commented 4 years ago

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!

Bojne commented 4 years ago

yarn work for me too!

tomgrigory commented 3 years ago

nothing's working for me.

rickschmoo commented 3 years ago

same issue building Gatsby site (Mac M1).

This worked: rm -rf node_modules rm package-lock.json npm install sharp npm install

Udit-takkar commented 3 years ago

@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
twobitEDD commented 3 years ago

@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

I'm having this same issue trying to upgrade a site, any guidance would be greatly appreciated.

dannyrojas28 commented 3 years ago

@rickschmoo @twobitEDD Hi, did you manage to fix it? I have the same problem in OS M1, any contribution comes in handy!

twobitEDD commented 3 years ago

Yes, I was able to do the following steps and was able to build:

sudo rm -rf node_modules
sudo rm package-lock.json
sudo npm install sharp --unsafe-perm
sudo gatsby build

https://geedew.com/What-does-unsafe-perm-in-npm-actually-do/

I'm still not sure why this happened...

eivindml commented 2 years ago

Same issue form me on M1 mac with pnpm.