我的package.json中有脚本块
"scripts": {
"start": "node ./node_modules/nodemon/bin/nodemon.js config/referenceBooks/girlsTypeInsert.js && src/app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
但是在执行了我的第一个脚本girlsgirlTypeInsert.js
之后var GirlType = require("../../models/girlType");
var mongoose = require('mongoose');
var db = mongoose.connection;
mongoose.connect('mongodb://localhost:27017/posts');
db.on("error", console.error.bind(console, "connection error"));
db.once("open", function(callback){
console.log("Connection Succeeded");
});
GirlType.count({}, function(err, c) {
if (c > 4) {
console.log('Girls types already in db');
db.close();
} else {
GirlType.insertMany([{ name: "Shere"},
{ name: "Kaori Nazuka"},
{ name: "Main"},
{ name: "Reone"},
{ name: "Asakawa"}], function(err) {
if (err) throw err;
console.log("Girls types inserted in db");
db.close();
});
}
});
nodemon给我消息
[nodemon]干净出口-等待更改,然后重新启动
启动下一个脚本app.js时需要更改什么?
答案 0 :(得分:1)
您应该替换
config / referenceBooks / girlsTypeInsert.js && src / app.js“
到
-exec \“ config / referenceBooks / girlsTypeInsert.js && src / app.js \”“