Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Installing Gatsby Starter 'Something went wrong installing the "sharp" module'

Problem

I am trying to set up a Gatsby starter project on Windows. Specifically, this starter project: https://www.gatsbyjs.com/starters/hasura/gatsby-gitbook-starter/

Versions:

Node: v14.10.1 npm: 6.14.8 Gatsby CLI version: 2.12.99 Gatsby version: 2.18.10

Initial Steps that created error:

I opened a new terminal and ran the Gatsby Starter script according to the documentation:

"gatsby new gatsby-gitbook-starter https://github.com/hasura/gatsby-gitbook-starter"

After the initial starter is cloned successfully I am instructed to cd into the directory and run "gatsby-develop".

This throws the following error:

success open and validate gatsby-configs - 0.081s

 ERROR 


Something went wrong installing the "sharp" module

Cannot find module '../build/Release/sharp.node'
Require stack:
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\sharp\lib\constructor.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\sharp\lib\index.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby-plugin-sharp\safe-sharp.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby-plugin-sharp\index.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby-plugin-sharp\gatsby-node.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby\dist\bootstrap\resolve-module-exports.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby\dist\bootstrap\load-plugins\validate.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby\dist\bootstrap\load-plugins\load.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby\dist\bootstrap\load-plugins\index.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby\dist\bootstrap\index.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby\dist\commands\develop.js
- C:\Users\mxgel\AppData\Roaming\npm\node_modules\gatsby-cli\lib\create-cli.js
- C:\Users\mxgel\AppData\Roaming\npm\node_modules\gatsby-cli\lib\index.js
- C:\Users\mxgel\AppData\Roaming\npm\node_modules\gatsby-cli\cli.js

- Remove the "node_modules/sharp" directory, run "npm install" and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
- Search for this error at https://github.com/lovell/sharp/issues


⠋ load plugins

My hunch is that this error is being thrown because of some global package manager configuration that I can't figure out, not the Sharp dependency itself. My goal is to use this Gatsby starter to streamline the process of project documentation.

Describe what you’ve tried

Followed Error Recommendations

My first step was to try the recommendation thrown by the error itself.

I tried removing the node_modules/sharp directory and running npm install but it gave me no errors and did not fix the problem. Its output from the NPM install was as follows.

added 2 packages from 60 contributors and audited 2713 packages in 12.906s

54 packages are looking for funding
  run `npm fund` for details

found 1219 vulnerabilities (1168 low, 2 moderate, 49 high)
  run `npm audit fix` to fix them, or `npm audit` for details

Removed Sharp Module, Reinstalled with Verbose Flag

Assuming that the 'verbose' flag would help, I removed the module and package-lock.json and ran npm install sharp --verbose:

npm info it worked if it ends with ok
npm verb cli [
npm verb cli   'C:\\nodejs\\node.exe',
npm verb cli   'C:\\Users\\mxgel\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli   'install',
npm verb cli   'sharp',
npm verb cli   '--verbose'
npm verb cli ]
npm info using [email protected]
npm info using [email protected]
npm verb npm-session 166ad6819380c39e
npm http fetch GET 304 https://registry.npmjs.org/sharp 240ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/sharp/-/sharp-0.26.1.tgz 103ms (from cache)
npm timing stage:loadCurrentTree Completed in 3562ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 44ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 938ms
npm http fetch GET 304 https://registry.npmjs.org/semver 85ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/fsevents 114ms (from cache)
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm http fetch GET 304 https://registry.npmjs.org/bindings 145ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/file-uri-to-path 101ms (from cache)
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 8627ms
npm timing stage:loadIdealTree Completed in 10371ms
npm timing stage:generateActionsToTake Completed in 190ms
npm verb correctMkdir C:\Users\mxgel\AppData\Roaming\npm-cache\_locks correctMkdir not in flight; initializing
npm verb makeCacheDir UID & GID are irrelevant on win32
npm verb lock using C:\Users\mxgel\AppData\Roaming\npm-cache\_locks\staging-cfcdc7ee6147183b.lock for C:\code\Sutro\gatsby-gitbook-starter2\node_modules\.staging
npm timing action:extract Completed in 291ms
npm timing audit submit Completed in 321ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 324ms
npm timing audit body Completed in 4ms
npm timing action:finalize Completed in 19ms
npm timing action:refresh-package-json Completed in 93ms
npm info lifecycle [email protected]~preinstall: [email protected]
npm info lifecycle [email protected]~preinstall: [email protected]
npm info lifecycle [email protected]~preinstall: [email protected]
npm info lifecycle [email protected]~preinstall: [email protected]
npm timing action:preinstall Completed in 7ms
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm verb linkBins [
npm verb linkBins   { semver: 'bin/semver.js' },
npm verb linkBins   'C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\sharp\\node_modules\\.bin',
npm verb linkBins   false
npm verb linkBins ]
npm info linkStuff [email protected]
npm timing action:build Completed in 68ms
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~install: ignored because ignore-scripts is set to true [email protected]
npm timing action:install Completed in 32ms
npm info lifecycle [email protected]~postinstall: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm timing action:postinstall Completed in 46ms
npm verb unlock done using C:\Users\mxgel\AppData\Roaming\npm-cache\_locks\staging-cfcdc7ee6147183b.lock for C:\code\Sutro\gatsby-gitbook-starter2\node_modules\.staging
npm timing stage:executeActions Completed in 648ms
npm timing stage:rollbackFailedOptional Completed in 1ms
npm timing stage:runTopLevelLifecycles Completed in 15394ms
npm verb saving [ { name: 'sharp', spec: '^0.26.1', save: 'dependencies' } ]
npm verb shrinkwrap skipping write for package.json because there were no changes.
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle [email protected]~shrinkwrap: [email protected]
npm notice created a lockfile as package-lock.json. You should commit this file.
npm info lifecycle [email protected]~postshrinkwrap: [email protected]
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\babel-plugin-add-module-exports\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.1 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
npm WARN [email protected] requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.
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.

+ [email protected]
added 4 packages from 66 contributors and audited 2666 packages in 16.799s

60 packages are looking for funding
  run `npm fund` for details

found 1206 vulnerabilities (1157 low, 2 moderate, 47 high)
  run `npm audit fix` to fix them, or `npm audit` for details
npm verb exit [ 0, true ]
npm timing npm Completed in 18411ms
npm info ok

Existing Stack Overflow Solutions

After some research, I found that ignoring scripts might be the issue. I've tried setting ignore-scripts to true using the following command:

npm install sharp --ignore-scripts

This still did not fix the issue, and threw the same error.

The, I tried deleting my entire node modules folder and the package-lock.json, and then the following command:

npm install --unsafe-perm

The Sharp Error was still thrown after using 'gatsby develop'

Some more research. Again, trying to see if it was related to NPM, I ran the following to no avail:

npm rebuild

I Even Tried Yarn

Removing all of my modules and retrying the entire process using yarn did not fix the issue. I'm only listing this as an attempt to illustrate my desperation. I can post some of the yarn results, but long story short the Sharp module just straightup refuses to let me download a certain package from the Sharp module when using the Yarn install methods. I was even able to trace it down to the exact tvg module that refused to download, but I have no way of fixing this.

Thanks again for your time and patience, and info helps!

like image 605
Max Geller Avatar asked Sep 21 '20 17:09

Max Geller


Video Answer


1 Answers

@Ferran pointed me in the best direction: the Gatsby documentation.

Not sure what caused this error, but I completely reset my Windows 10 and then reinstalled Node, NPM, Gatsby from scratch.

All commands working fine now, with no sharp module errors! Must have been some environment conflicts on my drive.

like image 125
Max Geller Avatar answered Oct 19 '22 06:10

Max Geller