在Heroku上的猫鼬上找不到模块

时间:2019-08-04 11:34:17

标签: node.js heroku npm mongoose mongoose-schema

我的heroku应用程序出现错误,该应用程序是 2019-08-03T10:56:56.753066 + 00:00应用程序[web.1]:错误:找不到模块'./models/Marker'。< / strong> 我已经在上面看到topic了,但是对我不起作用(删除node_modules包不起作用/将node_modules添加到.gitignore)

我的package.json:

{
  "name": "node_passport_login",
  "version": "2.0.0",
  "description": "Node.js authentication with Passport",
  "main": "app.js",
  "scripts": {
    "start": "node app.js",
    "dev": "nodemon app.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "connect-flash": "^0.1.1",
    "ejs": "^2.6.1",
    "express": "^4.17.1",
    "express-ejs-layouts": "^2.5.0",
    "express-session": "^1.15.6",
    "mongodb": "^3.3.0-beta2",
    "mongoose": "^5.6.7",
    "overpass-frontend": "^2.4.3",
    "passport": "^0.4.0",
    "passport-local": "^1.0.0",
    "socket.io": "^2.2.0",
    "socketio": "^1.0.0"
  },
  "devDependencies": {
    "nodemon": "^1.19.1"
  },
  "engines": {
    "node": "10.15.0"
  }
}


需要模型的行:

const Marker = require('./models/Marker');

整个错误:

2019-08-04T11:27:42.587474+00:00 heroku[web.1]: Starting process with command node app.js
2019-08-04T11:27:44.635440+00:00 heroku[web.1]: State changed from starting to crashed
2019-08-04T11:27:44.616214+00:00 heroku[web.1]: Process exited with status 1
2019-08-04T11:27:44.560379+00:00 app[web.1]: internal/modules/cjs/loader.js:583
2019-08-04T11:27:44.560407+00:00 app[web.1]: throw err;
2019-08-04T11:27:44.560409+00:00 app[web.1]: ^
2019-08-04T11:27:44.560410+00:00 app[web.1]:
2019-08-04T11:27:44.560412+00:00 app[web.1]: Error: Cannot find module './models/Marker'
2019-08-04T11:27:44.560416+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
2019-08-04T11:27:44.560418+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:507:25)
2019-08-04T11:27:44.560422+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:637:17)
2019-08-04T11:27:44.560424+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:22:18)
2019-08-04T11:27:44.560425+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:7:16)
2019-08-04T11:27:44.560427+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:689:30)
2019-08-04T11:27:44.560428+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
2019-08-04T11:27:44.560430+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:599:32)
2019-08-04T11:27:44.560431+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
2019-08-04T11:27:44.560433+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:530:3)
2019-08-04T11:27:44.560434+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
2019-08-04T11:27:44.560435+00:00 app[web.1]: at startup (internal/bootstrap/node.js:283:19)
2019-08-04T11:27:44.560437+00:00 app[web.1]: at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

heroku local web有效。

编辑:./models/Marker是猫鼬模式模块导出的目录

1 个答案:

答案 0 :(得分:0)

问题是我在Windows上,因此不区分大小写,我的文件是marker.js而不是Marker.js,因此它可以在本地运行,但在Linux上,它必须完全相同的名称