无法运行Gatsby项目



当我运行Gatsby v2.19.19时,我得到以下错误

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

问题是,如果我切换到高于14.15.0的版本,无论我做什么,我的一些依赖项都不会安装。例如,gatsby-plugin-favicongatsby-transformer-sharpgatsby-plugin-sharp,它们都依赖于名为sharp的包

我也不能使用节点v12安装dependencies,然后切换到v14并运行相同包的项目原因(文档明确表示必须在相同版本的节点上安装并运行(

此外,在Gatsby v2->v3迁移指南指出,v3所需的最低节点版本是12.13.0。考虑到我使用v2,它甚至应该低于这个值,因此我不理解说我必须具有14.15.0或更高版本的错误。

这是我的package.json文件

"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"
}

我在节点v14.15.0或更高版本上安装上述软件包时遇到的错误

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.

您尝试过使用libvips依赖项吗?

根据一些GitHub线程的说法,问题似乎是libvipsgatsby-plugin-sharp使用的sharp的依赖项(存在于您的package.json中(。为了确认此插件是您问题的原因,请尝试将其删除并重新安装模块。

要绕过此问题,您可以尝试手动安装libvips

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

当然,这是假设一个MacOS系统。

其他线程建议从npm转换为纱线。

相关问题:

  • Gatsby new未能安装锋利的包装并断裂

相关内容

  • 没有找到相关文章

最新更新