简体   繁体   English

当我的节点版本比请求的版本更新时,为什么会收到有关我的节点版本的错误?

[英]Why am I getting an error about my node version when I have a newer version than is requested?

I'm working on a React project that is deployed using heroku.我正在开发一个使用 heroku 部署的 React 项目。 I just made an update to master and the pipeline failed.我刚刚对 master 进行了更新,但管道失败了。 I've seen others ask what to do when they get "The engine "node" is incompatible with this module."我见过其他人在收到“引擎“节点”与此模块不兼容时询问该怎么做。 errors when they have an older version of node.当他们有旧版本的节点时出错。 However, my pipeline failure indicates "Expected version "12.18.1". Got "10.23.0"".但是,我的管道失败表明“预期版本“12.18.1”。得到“10.23.0””。 Since I have a newer version of node in my project I'm a bit confused on this.由于我的项目中有一个较新版本的节点,因此我对此感到有些困惑。 The files I cloned from the project's repo are what gave me the versions I'm using as I've verified prior commits were also using the 12.18.1 version.我从项目的 repo 克隆的文件给了我我正在使用的版本,因为我已经验证过之前的提交也使用了 12.18.1 版本。 Does anyone have thoughts on this?有没有人对此有想法?

You will probably need to differentiate between your local version and the version used on heroku when deployed.您可能需要区分本地版本和部署时在 heroku 上使用的版本。 Check this documenation link .检查此文档链接 Copied below复制如下

You should always specify a Node.js version that matches the runtime you're developing and testing with.您应该始终指定一个与您正在开发和测试的运行时相匹配的 Node.js 版本。 To find your version locally:要在本地查找您的版本:

node --version

First, ensure that your application is using the heroku/nodejs buildpack首先,确保您的应用程序正在使用 heroku/nodejs buildpack

heroku buildpacks

Now, use the engines section of the package.json to specify the version of Node.js to use on Heroku.现在,使用 package.json 的引擎部分来指定要在 Heroku 上使用的 Node.js 版本。 Drop the 'v' to save only the version number:删除“v”以仅保存版本号:

{
  "name": "myapp",
  "description": "a really cool app",
  "version": "1.0.0",
  "engines": {
    "node": "12.x"
  }
}

It's recommended to use an x in the patch to get the latest patch updates from Node.建议在补丁中使用 x 来从 Node.js 获取最新的补丁更新。 A minor range (eg, 12.16) and an exact version (eg, 12.16.3) can be specified too.也可以指定小范围(例如 12.16)和精确版本(例如 12.16.3)。

  • run this command to install nvm : curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash运行以下命令安装 nvm: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
  • then run: nvm install 12.18.1然后运行: nvm install 12.18.1

If you are getting an error of NVM then run: source ~/.nvm/nvm.sh如果您收到 NVM 错误,请运行: source ~/.nvm/nvm.sh

see How to change to an older version of Node.js请参阅如何更改为旧版本的 Node.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 编写代码后,如何将loopback.io更新到新版本? - how can I update loopback.io to a newer version when I already have my code written? 当我拥有键和值时,为什么会出现错误? - Why am I getting the error when I have the key and value? 我的 Node.JS 应用程序使用较新版本的 Handlebars 错误预编译了获取模板? - Getting template was precompiled with a newer version of Handlebars error with my Node.JS app? 尝试运行Node App时出现错误 - i am getting error when try to run my Node App 为什么在运行我的代码时会收到错误“UnhandledPromiseRejectionWarning”? - Why am I getting error "UnhandledPromiseRejectionWarning" when running my code? npm WARN弃用了minimatch@2.0.10,但我有一个更新的版本 - npm WARN deprecated minimatch@2.0.10 but I have a newer version 当我运行npm测试时,为什么较新版本的mocha不会输出测试详细信息? - Why does newer version of mocha not output test details when I run npm test? 我已经尝试安装 node js 4.3.2 版本但它给出了错误 - I have try to install node js 4.3.2 version but it give error 我使用的是哪个版本的节点? - Which version of node am I using? Mongoose:增加我的文档版本号不起作用,我在尝试保存时遇到版本错误 - Mongoose: Incrementing my documents version number doesn't work, and I'm getting a Version Error when I try to save
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM