Javascript 为什么Postgres会导致';[nodemon]清除退出-在重新启动前等待更改';?
当我试图运行我的“npm开始”脚本(使用localhost端口9000进行开发)时,我所有使用Postgres的项目(即使是我已经几周或几个月没有接触过的项目)都会崩溃。唯一的错误指示是“[nodemon]清除退出-在重新启动之前等待更改” 但是,在我的server/index.js文件中,当我替换以下内容时:Javascript 为什么Postgres会导致';[nodemon]清除退出-在重新启动前等待更改';?,javascript,node.js,postgresql,nodemon,Javascript,Node.js,Postgresql,Nodemon,当我试图运行我的“npm开始”脚本(使用localhost端口9000进行开发)时,我所有使用Postgres的项目(即使是我已经几周或几个月没有接触过的项目)都会崩溃。唯一的错误指示是“[nodemon]清除退出-在重新启动之前等待更改” 但是,在我的server/index.js文件中,当我替换以下内容时: db.sync() .then(() => { console.log(chalk.blue('database is synced!')); app.list
db.sync()
.then(() => {
console.log(chalk.blue('database is synced!'));
app.listen(PORT, (err) => {
if (err) throw err;
console.log(chalk.green(`server running on ${PORT}`));
});
});
仅使用app.listen部分:
app.listen(PORT, (err) => {
if (err) throw err;
console.log(chalk.green(`server running on ${PORT}`));
});
然后,应用程序至少可以在本地主机端口9000上加载和访问(尽管显然没有需要数据库的功能)
我有一些项目使用相同的启动程序/样板代码(和相同的脚本),但是使用Mongoose/MongoDB可以很好地处理所有数据库功能,而且没有问题。我已经多次确保我的导入/导出是一致的(同样,代码本身在几周内没有改变)
我还尝试了以下方法:
db.sync()
.then(() => {
console.log(chalk.blue('database is synced!'));
app.listen(PORT, (err) => {
if (err) throw err;
console.log(chalk.green(`server running on ${PORT}`));
});
});
const Sequelize = require('sequelize');
const chalk = require('chalk');
const DB_NAME = 'boiler';
module.exports = new Sequelize(process.env.DATABASE_URL || `postgres://localhost:5432/${DB_NAME}`, {
logging: false,
});
package.json脚本-种子设定也不起作用,但运行种子设定脚本不会产生任何错误消息
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack -w & nodemon server/index.js",
"build": "webpack",
"db-init": "pg-init boiler",
"postinstall": "npm run db-init",
"seed": "node server/db/seed.js"
},