如何让 Heroku 使用节点 14.x 而不是 12.x?

pup*_*eno 5 heroku node.js

我需要 Heroku 使用 NodeJS 14 而不是 12,我该怎么做?在我的计算机上,我使用 Node 14,并且我在引擎中定义它package.json(在我的存储库的根目录下):

{
  "engines": {
    "node": "14.x"
  }
  ...
}
Run Code Online (Sandbox Code Playgroud)

我安装了 buildpackheorku/nodejsheroku/railsbuildpack,因为这是带有 webpack 的 Ruby on Rails 应用程序:

在此输入图像描述

但是当我在 Heroku 上运行测试时,我收到此错误:

Error: Missing binding /app/node_modules/node-sass/vendor/linux-x64-72/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 12.x
Found bindings for the following environments:
  - Linux 64-bit with Unsupported runtime (88)
Run Code Online (Sandbox Code Playgroud)

如果我解决了 CI 中的问题,部署时仍然会遇到麻烦:

-----> Installing node-v12.16.2-linux-x64
-----> Installing yarn-v1.22.4
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       yarn install v1.22.4
       [1/5] Validating package.json...
       error imok@0.1.0: The engine "node" is incompatible with this module. Expected version "14.x". Got "12.16.2"
       error Found incompatible module.
       info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Run Code Online (Sandbox Code Playgroud)

小智 9

文档中它说:

如果您的 Ruby 应用程序需要特定版本的 Node,您应该使用多个构建包首先安装 Node,然后安装 Ruby。

这意味着如果您部署了 Rails 应用程序,则需要删除所有构建包,然后按照正确的顺序重新添加它们,先添加heroku/node,然后添加heroku/rails