【发布时间】:2022-04-29 02:26:22
【问题描述】:
我正在尝试部署我的 node.js 应用程序数周,但我无法部署它,请有人帮我部署它,我已经完成了所有工作,但 Heroku 仍然显示应用程序错误。 请帮助解决这个问题,我的 Heroku 日志中出现这些错误
Starting process with command `node index.js`
2022-02-19T12:38:49.101275+00:00 app[web.1]: /app/node_modules/mongoose/lib/cursor/QueryCursor.js:144
2022-02-19T12:38:49.101284+00:00 app[web.1]: QueryCursor.prototype.map = function(fn) {
2022-02-19T12:38:49.101285+00:00 app[web.1]: ^
2022-02-19T12:38:49.101285+00:00 app[web.1]:
2022-02-19T12:38:49.101286+00:00 app[web.1]: TypeError: Cannot assign to read only property 'map' of object '#<QueryCursor>'
2022-02-19T12:38:49.101286+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongoose/lib/cursor/QueryCursor.js:144:27)
2022-02-19T12:38:49.101286+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1097:14)
2022-02-19T12:38:49.101286+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
2022-02-19T12:38:49.101287+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:975:32)
2022-02-19T12:38:49.101287+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-02-19T12:38:49.101287+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:999:19)
2022-02-19T12:38:49.101288+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-02-19T12:38:49.101288+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongoose/lib/query.js:12:21)
2022-02-19T12:38:49.101288+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1097:14)
2022-02-19T12:38:49.101288+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
2022-02-19T12:38:49.101292+00:00 app[web.1]:
2022-02-19T12:38:49.101292+00:00 app[web.1]: Node.js v17.5.0
2022-02-19T12:38:49.222099+00:00 heroku[web.1]: Process exited with status 1
2022-02-19T12:38:49.270154+00:00 heroku[web.1]: State changed from starting to crashed
2022-02-19T12:38:49.273378+00:00 heroku[web.1]: State changed from crashed to starting
2022-02-19T12:38:52.851143+00:00 heroku[web.1]: Starting process with command `node index.js`
2022-02-19T12:38:54.692822+00:00 app[web.1]: /app/node_modules/mongoose/lib/cursor/QueryCursor.js:144
2022-02-19T12:38:54.692840+00:00 app[web.1]: QueryCursor.prototype.map = function(fn) {
2022-02-19T12:38:54.692841+00:00 app[web.1]: ^
2022-02-19T12:38:54.692841+00:00 app[web.1]:
2022-02-19T12:38:54.692841+00:00 app[web.1]: TypeError: Cannot assign to read only property 'map' of object '#<QueryCursor>'
2022-02-19T12:38:54.692842+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongoose/lib/cursor/QueryCursor.js:144:27)
2022-02-19T12:38:54.692842+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1097:14)
2022-02-19T12:38:54.692842+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
2022-02-19T12:38:54.692843+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:975:32)
2022-02-19T12:38:54.692843+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-02-19T12:38:54.692843+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:999:19)
2022-02-19T12:38:54.692844+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-02-19T12:38:54.692844+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongoose/lib/query.js:12:21)
2022-02-19T12:38:54.692844+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1097:14)
2022-02-19T12:38:54.692844+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
2022-02-19T12:38:54.692845+00:00 app[web.1]:
2022-02-19T12:38:54.692845+00:00 app[web.1]: Node.js v17.5.0
2022-02-19T12:38:54.845812+00:00 heroku[web.1]: Process exited with status 1
2022-02-19T12:38:55.309883+00:00 heroku[web.1]: State changed from starting to crashed
2022-02-19T12:38:56.377269+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=i-book-backend.herokuapp.com request_id=bc0cecd2-3197-43c3-9b15-6adbfa62943a fwd-6adbfa62943a fwd="150.129.159.93" dyno= connect= service= status=503 bytes= protocol=https
2022-02-19T12:38:57.014602+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=i-book-backend.herokuapp.com request_id=26338aa4-0e9b-41d4-b2b4-9cf32b-41d4-b2b4-9cf32ab946fa fwd="150.129.159.93" dyno= connect= service= status=503 bytes= protocol=https
2022-02-19T12:40:27.841439+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=i-book-backend.herokuapp.com request_id=9ecc5d99-e1fe-47cc-815c-ffde34a9568b fwd-ffde34a9568b fwd="150.129.159.93" dyno= connect= service= status=503 bytes= protocol=https
2022-02-19T12:40:28.357238+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=i-book-backend.herokuapp.com request_id=2d493654-9b7c-40f7-9e35-073c3c-40f7-9e35-073c3b950e51 fwd="150.129.159.93" dyno= connect= service= status=503 bytes= protocol=https
这是我的 index.js 文件
const connectToMongo = () => { require('./db') };
const express = require('express')
var cors = require('cors')
connectToMongo();
const dotenv = require('dotenv')
dotenv.config();
const app = express()
// app.use(cors())
app.use(cors({
origin: "*",
}));
const port = process.env.PORT || 5000
https://runkit.com/
app.use(express.json())
app.use('/api/auth/', require('./routes/auth'))
app.use('/api/notes', require('./routes/notes'))
app.listen(port, () => {
console.log(`i-book backend app listening at http://${port}`)
})
如果我需要更多详细信息,请告诉我。
【问题讨论】:
标签: node.js mongodb date heroku webpack