Heroku engines.node (package.json) unspecified



我在将代码推送到Heroku时遇到问题
package.json

{
"name": "my-app",
"version": "0.1.0",
"engine": {
"node": "12.16.2",
"npm": "6.13.4"
},
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"bcrypt": "^4.0.1",
"body-parser": "^1.18.3",
"cookie-parser": "^1.4.3",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.4.20",
"nodemon": "^2.0.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "node server/index.js",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"backend": "nodemon server/index.js"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

输出

remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 12.x...
remote:        Downloading and installing node 12.16.1...
remote:        Using default npm version: 6.13.4
<!-- more stuff -->
remote: -----> Build
remote:        Running build
remote:        
remote:        > my-app@0.1.0 build /tmp/build_016788c07037e47ee5638bf5c1b1f631
remote:        > react-scripts build
remote:
remote:        Could not find a required file.
remote:          Name: index.html
remote:          Searched in: /tmp/build_016788c07037e47ee5638bf5c1b1f631/public
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! my-app@0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the my-app@0.1.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.yXjxR/_logs/2020-04-11T07_16_57_245Z-debug.log
remote: 
remote: -----> Build failed
remote:        
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        Some possible problems:
remote:
remote:        - Node version not specified in package.json
remote:          https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed

正如你所看到的,尽管我在package.json中指定了我的节点和npm版本,但Heroku没有识别它,我的推送被拒绝了。我试着在Heroku网站上订票,但由于这是一个免费的应用程序,他们不允许我在他们的帮助热线上询问。

edit
我通过Heroku将npm和节点版本升级到默认版本,但我得到了错误Could not find a required file.Name: index.html

我遇到了同样的问题。看起来Heroku还不支持12.16.2。请尝试使用package.json引擎部分中的12.16.1。

更改此

"发动机":{"节点":"12.16.2","npm":"6.13.4"},

"发动机":{"节点":"12.16.1","npm":"6.14.4"},

成功部署您的应用程序。您应该首先在项目文件夹的根目录中创建一个特定的文件,该文件的名称必须为.

Procfile

没有任何额外的扩展。Procfile文件的内容必须是web: node index.js或任何你的主文件。不要使用web: node run index.js,只有web: node index.js可以。

我的package.json没有"发动机";指定

添加"发动机":{"节点":"12.16.1"、"npm":"6.14.4"},在我的包中.json修复了

最新更新