Vin*_*aya 10 deployment heroku node.js
我有一个 Node 项目想要在 Heroku 上托管。我在 package.json (位于根目录中)中明确定义了 node 和 npm 版本,如下所示:
{
"name": "*********",
"version": "1.0.0",
"description": "**********",
"engines": {
"node": "8.x",
"npm": "6.x"
},
"private": true,
.....
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试将应用程序推送到 heroku 时。它仍然没有读取节点和 npm 版本。
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): unspecified (use
default)
remote: Resolving node version 10.x...
remote: Downloading and installing node 10.15.3...
remote: Using default npm version: 6.4.1
Run Code Online (Sandbox Code Playgroud)
我的情况有什么解决办法吗?不管怎样,谢谢你
Abh*_*yay 12
我通过在 package.json 文件中添加引擎解决了这个问题
"name": "myApp",
"version": "1.0.0",
"engines": {
"node": "14.17.0",
"npm": "6.14.13"
},
"main": "index.ts",
Run Code Online (Sandbox Code Playgroud)
参考链接:-https://help.heroku.com/6235QYN4/why-is-my-node-js-build-failing-because-of-no-matching-node-versions
Heroku 开发中心对此进行了正确记录。
正如您所看到的,构建日志显示没有指定节点版本。
engines.node(package.json):未指定
您的 package.json 是正确的,但您可能没有将应用程序设置为使用heroku/nodejsbuildpack。
使用它来检查正在使用的构建包。
$ heroku buildpacks
=== issuetriage Buildpack URLs
1. heroku/nodejs
$ heroku buildpacks:add heroku/nodejs
Buildpack added. Next release on issuetriage will use heroku/nodejs.
Run git push heroku master to create a new release using this buildpack.
Run Code Online (Sandbox Code Playgroud)
如果您发布完整的构建日志,可能会发现更多内容。
| 归档时间: |
|
| 查看次数: |
11431 次 |
| 最近记录: |