【问题标题】:Error: Cannot find module 'body-Parser' deploy HEROKU错误:找不到模块“body-Parser”部署 HEROKU
【发布时间】:2018-09-18 08:44:56
【问题描述】:

我到处找,找不到解决办法

出现的错误

package.json

 {
  "name": "apirest",
  "version": "1.0.0",
  "description": "API para consultar rucs de Paraguay por numero o nommbre",
  "main":"index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js"
  },
  "author": "Daniel Resoalbe resoalbe@gmail.com",
  "license": "ISC",
  "dependencies": {
    "bcrypt-nodejs": "0.0.3",
    "body-parser": "^1.18.3",
    "crypto": "^1.0.1",
    "express": "^4.16.3",
    "express-handlebars": "^3.0.0",
    "jwt-simple": "^0.5.1",
    "moment": "^2.22.2",
    "mongoose": "^5.2.15"
  },
  "devDependencies": {
    "nodemon": "^1.18.4"
  }
}

我在 Heroku 中寻找解决方案,但没有找到

【问题讨论】:

  • 您是否检查了输出底部附近列出的日志文件?
  • 在您的代码中的某处,您正在使用 body-Parser(大写 P),这显然不存在于依赖项中。应该是body-parser

标签: node.js api heroku


【解决方案1】:

这很可能是harshalgangurde 所说的拼写错误,顺便说一句,您甚至不需要安装正文解析器,它默认包含在 express 中。 您可以使用这些内置的中间件函数,例如:

app.use(express.json());
app.use(express.urlencoded({ extended: false }));

【讨论】:

    猜你喜欢
    • 2021-03-17
    • 2019-01-27
    • 2014-03-22
    • 2016-12-25
    • 2021-08-17
    • 1970-01-01
    • 2018-11-07
    • 2017-06-07
    • 1970-01-01
    相关资源
    最近更新 更多