首页 > 解决方案 > Heroku 推送被拒绝失败:npm ERR!404 未找到:事件流@3.3.6。这会导致构建失败

问题描述

我收到错误消息:

Heroku 推送被拒绝未能定义 node.js 节点未在 package.json 中定义

我的应用程序在本地工作,这是一个使用车把的 Express MongoDB。我的 gitignore 里面有 node_modules,奇怪的是我使用的是 nodemon 而不是 node。

包.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"

}

标签: mongodbexpressherokuhandlebars.js

解决方案


您需要在 package.json 中指定与您正在开发和测试的运行时相匹配的Node.js 版本。

请执行下列操作:

  1. 在您的 cmd 行类型中:node --version并查看您正在使用的 Node 版本。
  2. 在您的 package.json 中添加一个引擎部分,从步骤 1 中指定您的节点版本。例如类似于以下内容:

"engines": { "node": "10.3.0" }

有关更多信息,请查看 Nodejs buildpacks的 Heroku 文档


推荐阅读