简体   繁体   中英

Unable to run Gatsby project

When I run Gatsby v2.19.19 I get the following error

Gatsby requires Node.js 14.15.0 or higher (you have v12.13.0)

The problem is if that I switch to anything higher than 14.15.0 some of my dependecies won't install no matter what I do. For instance, gatsby-plugin-favicon gatsby-transformer-sharp gatsby-plugin-sharp that all depend on the package called sharp

I also can't install the dependecies using node v12 and then switch to v14 and run the project cause of the same package (the docs explicitly state that it has to be installed and run on the same version of node)

Also, in Gatsby v2 -> v3 migration guide it says that minimal required node version for v3 is 12.13.0. Given that I work with v2 it should even be lower than that, therefore I do not understand the error that says that I have to have 14.15.0 or above.

Here is my package.json file

  "scripts": {
    "develop": "gatsby develop",
    "build:develop": "OSS_ENV=staging gatsby build",
    "build": "OSS_ENV=production gatsby build",
    "serve": "gatsby serve"
  },
  "dependencies": {
    "@stripe/stripe-js": "^1.13.1",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "dotenv": "^8.2.0",
    "email-validator": "^2.0.4",
    "express": "^4.17.1",
    "gatsby-plugin-google-tagmanager": "^2.1.25",
    "gatsby-plugin-robots-txt": "^1.5.0",
    "gatsby-plugin-sitemap": "^2.2.27",
    "pngquant-bin": "^6.0.0",
    "superagent": "^6.1.0"
  },
  "devDependencies": {
    "antd": "^3.26.11",
    "axios": "^0.21.1",
    "gatsby": "^2.19.18",
    "gatsby-image": "^2.2.41",
    "gatsby-plugin-antd-v2": "^1.0.3",
    "gatsby-plugin-favicon": "^3.1.6",
    "gatsby-plugin-less": "^4.7.0",
    "gatsby-plugin-react-helmet": "^3.1.22",
    "gatsby-plugin-sass": "^3.2.0",
    "gatsby-plugin-sharp": "^2.4.5",
    "gatsby-plugin-typescript": "^2.1.27",
    "gatsby-source-filesystem": "^2.1.48",
    "gatsby-source-ghost": "^4.2.2",
    "gatsby-transformer-sharp": "^2.3.14",
    "less": "^4.1.1",
    "node-sass": "^5.0.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-helmet": "^6.1.0",
    "react-icons": "^4.2.0"
  }

The error I get while installing the packages I mentioned above on node v14.15.0 or above

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.23.4 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.23.4 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Have you tried playing with libvips dependency?

According to some GitHub threads , the issue seems that libvips is a dependency for sharp which gatsby-plugin-sharp uses (present in your package.json ). Just to confirm that this plugin is the cause of your issue, try removing it and reinstalling the modules again.

To bypass this issue you can try installing libvips manually:

rm -rf /Users/{username}/.npm/_libvips
brew install vips 
rm -rf node_modules
npm install

Of course, this assumes a MacOS system.

Other threads suggest switching from npm to yarn.

Related issues:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM