Gatsby: npx gatsby new has a problem with Sharp dependencie

Created on 2 Mar 2019  路  5Comments  路  Source: gatsbyjs/gatsby

Description

I can not create a new Gatsby project with npx

Steps to reproduce

npx gatsby new

Expected result

A gatsby boilerplate to develop

Actual result

error /Users/luislocon/Documents/Projects/React/gatsby/loconluis/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: <>/Documents/Projects/React/gatsby/loconluis/node_modules/sharp
Output:
info sharp Using cached <>/.npm/_libvips/libvips-8.7.0-darwin-x64.tar.gz
ERR! sharp zlib: unexpected end of file
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 info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp info spawn /usr/local/bin/python2
gyp info spawn args [ '/Users/luislocon/.nvm/versions/node/v10.15.0/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   '<>/Documents/Projects/React/gatsby/loconluis/node_modules/sharp/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '<>/.nvm/versions/node/v10.15.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '<>/.node-gyp/10.15.0/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/luislocon/.node-gyp/10.15.0',
gyp info spawn args   '-Dnode_gyp_dir=<>/.nvm/versions/node/v10.15.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=<>/.node-gyp/10.15.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=<>/Documents/Projects/React/gatsby/loconluis/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 WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
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
../src/common.cc:25:10: fatal error: 'vips/vips8' file not found
#include <vips/vips8>
         ^~~~~~~~~~~~
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/luislocon/.nvm/versions/node/v10.15.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "<>/.nvm/versions/node/v10.15.0/bin/node" "<>/.nvm/versions/node/v10.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd <>/Documents/Projects/React/gatsby/loconluis/node_modules/sharp

Environment

System:
    OS: macOS 10.14.3
    CPU: (4) x64 Intel(R) Core(TM) i5-6360U CPU @ 2.00GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node
    Yarn: 1.13.0 - ~/.nvm/versions/node/v10.15.0/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.0/bin/npm
  Languages:
    Python: 2.7.15 - /usr/local/bin/python
  Browsers:
    Chrome: 72.0.3626.119
    Firefox: 65.0.1
    Safari: 12.0.3
  npmPackages:
    gatsby: ^2.1.19 => 2.1.19
    gatsby-image: ^2.0.30 => 2.0.30
    gatsby-plugin-manifest: ^2.0.20 => 2.0.20
    gatsby-plugin-offline: ^2.0.24 => 2.0.24
    gatsby-plugin-react-helmet: ^3.0.7 => 3.0.7
    gatsby-plugin-sharp: ^2.0.23 => 2.0.23
    gatsby-source-filesystem: ^2.0.23 => 2.0.23
    gatsby-transformer-sharp: ^2.1.15 => 2.1.15

Others
Python 2.7.15

Most helpful comment

@loconluis could you try the tip specified here?

Generally - when an issue like this occurs it's most helpful to delete node_modules and try from a fresh install. npm cache clean can also help quite a bit!

All 5 comments

@loconluis could you try the tip specified here?

Generally - when an issue like this occurs it's most helpful to delete node_modules and try from a fresh install. npm cache clean can also help quite a bit!

Already works! Thanks for your help!

Great! So what was the solution?

Going to close this out--but if you could chime in with what helped you solve it, that would be great!

@DSchau As the comment you pinned, I delete the corrupt file that was giving problem <~/.npm/_libvips/libvips-8.7.0-linux-x64.tar.gz>, and ran the CLI again, and everything worked fine

For me, the problem persisted following the deletion of the tar file located at ~/.npm/_libvips/. That had to be reinstalled (on Mac I used brew install vips). Running the gatsby new command then worked.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dustinhorton picture dustinhorton  路  3Comments

hobochild picture hobochild  路  3Comments

3CordGuy picture 3CordGuy  路  3Comments

benstr picture benstr  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments