Hi
Creating a project following the quick start page fail for me.
I just installed Gatsby CLI on my machine. When running gatsby new gatsby-site
I get the following error:
error /Users/211103/Documents/projects/www/gatsby-site/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
Arguments:
Directory: /Users/211103/Documents/projects/www/gatsby-site/node_modules/sharp
Output:
info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.8.1/libvips-8.8.1-darwin-x64.tar.gz
fs.js:114
throw err;
^
Error: EACCES: permission denied, copyfile '/var/folders/53/5lf8gtcj0yjfr570zz1yf6mmmcpds1/T/37285-libvips-8.8.1-darwin-x64.tar.gz' -> '/Users/211103/.npm/_libvips/libvips-8.8.1-darwin-x64.tar.gz'
at Object.copyFileSync (fs.js:1728:3)
at WriteStream.<anonymous> (/Users/211103/Documents/projects/www/gatsby-site/node_modules/sharp/install/libvips.js:104:16)
at WriteStream.emit (events.js:198:13)
at lazyFs.close (internal/fs/streams.js:207:14)
at FSReqWrap.args [as oncomplete] (fs.js:140:20)
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info find Python using Python version 2.7.16 found at "/usr/bin/python"
gyp info spawn /usr/bin/python
gyp info spawn args [ '/Users/211103/.nvm/versions/node/v10.18.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/211103/Documents/projects/www/gatsby-site/node_modules/sharp/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/211103/.nvm/versions/node/v10.18.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/211103/Library/Caches/node-gyp/10.18.1/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/211103/Library/Caches/node-gyp/10.18.1',
gyp info spawn args '-Dnode_gyp_dir=/Users/211103/.nvm/versions/node/v10.18.1/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/211103/Library/Caches/node-gyp/10.18.1/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/211103/Documents/projects/www/gatsby-site/node_modules/sharp',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
TOUCH Release/obj.target/libvips-cpp.stamp
CXX(target) Release/obj.target/sharp/src/common.o
In file included from ../src/common.cc:25:
/usr/local/include/vips/vips8:35:10: fatal error: 'glib-object.h' file not found
#include <glib-object.h>
^~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/sharp/src/common.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/211103/.nvm/versions/node/v10.18.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/Users/211103/.nvm/versions/node/v10.18.1/bin/node" "/Users/211103/.nvm/versions/node/v10.18.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/211103/Documents/projects/www/gatsby-site/node_modules/sharp
ERROR
Command failed with exit code 1: yarnpkg
Error: Command failed with exit code 1: yarnpkg
- error.js:56 makeError
[lib]/[gatsby-cli]/[execa]/lib/error.js:56:11
- index.js:114 handlePromise
[lib]/[gatsby-cli]/[execa]/index.js:114:26
- next_tick.js:68 process._tickCallback
internal/process/next_tick.js:68:7
The project is created, but the modules failed to be fully installed.
I tried to run npm i and the module sharp seems to throw an error:
> [email protected] install /Users/211103/Documents/projects/vincent-humeau.com/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.8.1/libvips-8.8.1-darwin-x64.tar.gz
fs.js:114
throw err;
^
Error: EACCES: permission denied, copyfile '/var/folders/53/5lf8gtcj0yjfr570zz1yf6mmmcpds1/T/46113-libvips-8.8.1-darwin-x64.tar.gz
' -> '/Users/211103/.npm/_libvips/libvips-8.8.1-darwin-x64.tar.gz'
at Object.copyFileSync (fs.js:1728:3)
at WriteStream.<anonymous> (/Users/211103/Documents/projects/vincent-humeau.com/node_modules/sharp/install/libvips.js:104:16)
at WriteStream.emit (events.js:198:13)
at lazyFs.close (internal/fs/streams.js:207:14)
at FSReqWrap.args [as oncomplete] (fs.js:140:20)
TOUCH Release/obj.target/libvips-cpp.stamp
CXX(target) Release/obj.target/sharp/src/common.o
In file included from ../src/common.cc:25:
/usr/local/include/vips/vips8:35:10: fatal error: 'glib-object.h' file not found
#include <glib-object.h>
^~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/sharp/src/common.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/211103/.nvm/versions/node/v10.18.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/Users/211103/.nvm/versions/node/v10.18.1/bin/node" "/Users/211103/.nvm/versions/node/v10.18.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/211103/Documents/projects/vincent-humeau.com/node_modules/sharp
gyp ERR! node -v v10.18.1
gyp ERR! node-gyp -v v5.0.7
gyp ERR! not ok
npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
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.
Should be able to create a new project
Can't run the project
System:
OS: macOS Mojave 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.18.1 - ~/.nvm/versions/node/v10.18.1/bin/node
Yarn: 1.22.0 - /usr/local/bin/yarn
npm: 6.13.7 - ~/.nvm/versions/node/v10.18.1/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 80.0.3987.122
Firefox: 73.0
Safari: 13.0.5
npmPackages:
gatsby: ^2.19.7 => 2.19.22
gatsby-image: ^2.2.39 => 2.2.41
gatsby-plugin-manifest: ^2.2.39 => 2.2.42
gatsby-plugin-offline: ^3.0.32 => 3.0.35
gatsby-plugin-react-helmet: ^3.1.21 => 3.1.22
gatsby-plugin-sharp: ^2.4.3 => 2.4.5
gatsby-source-filesystem: ^2.1.46 => 2.1.48
gatsby-transformer-sharp: ^2.3.13 => 2.3.16
npmGlobalPackages:
gatsby-cli: 2.9.0
Thanks 馃榾
I tried on windows machine and no issue. When pulling the project on my machine and running npm i I still get the above error.
I found this error that might be related https://github.com/gatsbyjs/gatsby/issues/20320#issuecomment-573040166
I tried to install libvips and still the same issue
Are you able to npm i sharp on that machine?
You can try to clear ~/.npm and node_modules and then npm i sharp again. (Considering the permission error, you might have to do sudo rm -rf ~/.npm, but normally the sudo part should not be required for this)
Since the error seems to imply a permission problem in ~/.npm I kind of expect clearing that folder (it's a system wide npm cache folder) to solve all the things.
Perhaps you ran npm through sudo (directly or indirectly) which could be one explanation.
Thanks a lot @pvdz I had to run sudo rm -rf ~/.npm to fixe my issue. Now I get no issue when creating a new project.
i solve this isue by removing gatsby-transformer-sharp, gatsby-plugin-sharp , gatsby-plugin-manifest on the package.json and remove with sudo rm -rf node_modules and npm install, last step you can install package that u remove by npm i --save gatsby-transformer-sharp and etc
Most helpful comment
Thanks a lot @pvdz I had to run
sudo rm -rf ~/.npmto fixe my issue. Now I get no issue when creating a new project.