【发布时间】:2022-01-20 09:55:58
【问题描述】:
我在尝试运行我的代码时一直遇到这个错误...
[nodemon] 2.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
[nodemon] clean exit - waiting for changes before restart
这是我要运行的代码:
import app from "./server";
import mongodb from "mongodb";
import dotenv from "dotenv";
//configuiring dotenv for use
dotenv.config();
const MongoClient = mongodb.MongoClient;
const port = process.env.PORT || 8000; // if the port(5000 in this one) from dotenv file cant be accesed then access 8000
MongoClient.connect(process.env.RESTREVIEWS_DB_URI, {
poolsize: 50, //max no of users at a time
wtimeout: 2500, //timeout after 2500 ms
useNewUrlParse: true,
})
.catch((err) => {
//if connection fails
console.error(err.stack);
process.exit(1);
})
.then(async (client) => {
app.listen(port, () => {
console.log(`listening on the port ${port}`);
});
});
// -- AND WE ARE DONE WITH THE DATABASE AND HAVE STARTED OUR WEB SERVER --
我尝试将执行策略更改为无限制模式和远程,但它仍然不起作用。如果有人能帮我弄清楚我做错了什么,那就太好了!
【问题讨论】:
-
运行
node server.js时会发生什么? Nodemon 有时会中断,这可能是问题所在。 -
Nothing... 它只是在运行
node server.js时提示输入下一个输入
标签: javascript mongodb mern web-development-server nodemon