引擎“node”与此模块不兼容。

3
我遇到了问题,无法将最近从 Gatsby 项目中进行的更改部署到 Netlify。在本地运行项目的启动和构建命令没有问题。
以下是问题描述:
error gatsby@3.6.0: The engine "node" is incompatible with this module. Expected version ">=12.13.0". Got "10.24.1"

这里是仓库和部署日志的链接:

https://github.com/simonxcode/simonxcode.com https://app.netlify.com/sites/simonxcode/deploys/60aeec1c22d2e5154232e488

我知道这个问题之前被问过很多次,但是常见的解决方案都对我没用。也许我执行它们时有误或者漏了其他什么东西。
以下是我尝试过的解决方案:
  1. execute yarn --ignore-engines from How to ignore incompatible engine "node" error on installing npm dependencies with yarn?

  2. set node variable in .env file (not visible in repo because .gitignore) from Setting Environment Variables for Node to retrieve

     //.env file
     NODE_ENV=development
    
  3. add "engine": { "node": ">=12.13.0"} to package.json from The engine "node" is incompatible with this module

  4. Update node with brew update and brew upgrade node from The engine "node" is incompatible with this module

    • Note 1: Before updating Homebrew, I deleted node_modules/ and yarn.lock files

    • Note 2: after executing brew postinstall node and brew link --overwrite node, I no longer have access to node, yarn or gatsby when checking with node -v, yarn -v and gatsby -v


1
你只需要更新Node,这并不难。有多种方法可以做到这一点。听起来你在这方面遇到了问题,我建议你把问题改为关于更新Node的问题,并提供更多细节。 - JBallin
最初是很久以前了,哈哈。我相信当时使用的是npm,之后我用yarn和homebrew进行了更新。 - simonxcode
1
我会研究如何完全卸载机器上的node,然后简单地运行“brew install node yarn”。如果需要更改版本,您可以稍后在此基础上设置nvm。 - JBallin
是的,在这个阶段最好从头开始。我会继续做这件事。谢谢! - simonxcode
4个回答

2
截至2021年11月21日,如果出现期望版本“>=14.15.0”。得到“12.13.0”的情况。只需通过以下方式更新您的Netlify环境变量

键: NODE_VERSION 值:14.15.0

这对我来说很好用。


2

我也试过了,谢谢! - Miktad Tahir Durak

1

我曾经遇到过一个类似的问题,这是因为我使用了一个过时的NodeJs版本。

请检查: npm get 看看你是否将严格的引擎检查设置为true。

如果是这样,并且你不能简单地升级node: npm set engine-strict false

在升级项目的过程中,这个方法解决了我的问题。


0
我通过使用nvm来解决了这个问题。Nvm是Node版本管理器。我只需运行nvm install 12.13.0,然后一切都正常工作了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接