我遇到了错误:
Heroku推送被拒绝,无法定义未在package.json中定义的node.js节点
我的应用程序在本地运行,这是一个使用把手的Express MongoDB。我的gitignore中有node_modules,奇怪的是我正在使用nodemon而不是node。
package.json:
{
"name": "Jukebox",
"version": "1.1.0",
"engines": {
"node": "11.3.0",
"npm": "6.4.1"
},
"private": true,
"scripts": {
"start": "node ./bin/www",
"dev": "nodemon ./bin/www"
},
"dependencies": {
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"dotenv": "^6.1.0",
"express": "~4.16.0",
"hbs": "~4.0.1",
"http-errors": "~1.6.2",
"method-override": "^3.0.0",
"mongoose": "^5.3.6",
"morgan": "~1.9.0",
"nodemon": "^1.18.4"
},
"description": "Jukebox is an app where users can add their favorite songs for others to discover. There will be a maximum number of 32 songs that can be added. When user selects genre the artists of that genre will populate the grid and a button will appear to add artist.",
"main": "app.js",
"repository": {
"type": "git",
"url": "git+https://github.com/chuckderosier/Jukebox.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/chuckderosier/Jukebox/issues"
},
"homepage": "https://github.com/chuckderosier/Jukebox#readme"
}
答案 0 :(得分:1)
您需要在package.json中指定与之匹配的Node.js版本 您用于开发和测试的运行时。
执行以下操作:
node --version
,然后查看要使用的Node版本。 "engines": {
"node": "10.3.0"
}
有关更多信息,请查看Nodejs buildpacks的Heroku文档