首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我收到这个错误TypeError:无法指定读取对象'#<QueryCursor>‘2022-02-19T12:38:49.101286+00:00应用程序的只读属性“map”[web.1]:

我收到这个错误TypeError:无法指定读取对象'#<QueryCursor>‘2022-02-19T12:38:49.101286+00:00应用程序的只读属性“map”[web.1]:
EN

Stack Overflow用户
提问于 2022-02-19 12:50:38
回答 2查看 2.2K关注 0票数 2

我试图部署我的node.js应用数周,但我无法部署它,请有人帮助我部署这个,我已经做了一切,但仍然Heroku说应用程序错误。请帮助解决这个问题,我在我的Heroku日志中得到了这些错误。

代码语言:javascript
复制
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文件

代码语言:javascript
复制
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}`)
})

请告诉我,如果我需要更多的细节从我身边。

EN

回答 2

Stack Overflow用户

发布于 2022-02-20 06:29:26

根据这个问题 in GitHub,这是一个节点最新版本v17.5.0和猫鼬尚未解决的问题。

为了临时修复此问题,请更改package.json文件中的Nodejs引擎版本,如下所示:

代码语言:javascript
复制
"engines": { "node": ">=12.0.0 <17.5.0" }

注意:为了重新安装Nodejs,您需要再次部署应用程序。

票数 4
EN

Stack Overflow用户

发布于 2022-04-28 18:26:22

节点17.6.0修复了这个问题,如果您正在使用诸如内置fetch之类的实验特性

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71185161

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档