gpt4 book ai didi

node.js - 如何让 Heroku 使用 Node 14.x 而不是 12.x?

转载 作者:行者123 更新时间:2023-12-04 12:23:03 42 4
gpt4 key购买 nike

我需要 Heroku 使用 NodeJS 14 而不是 12,我该怎么做?在我的计算机上,我使用的是 Node 14,我在 package.json 上的引擎中定义了它(在我的 repo 的根):

{
"engines": {
"node": "14.x"
}
...
}
我有 heorku/nodejs以及 heroku/rails安装 buildpack 因为这是一个带有 webpack 的 Ruby on Rails 应用程序:
enter image description here
但是当运行我的测试是 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)
如果我解决了 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.

最佳答案

the documentation它说:

If you need a specific version of node for your Ruby application you should use multiple buildpacks to first install node then install Ruby.


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

关于node.js - 如何让 Heroku 使用 Node 14.x 而不是 12.x?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66445057/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com