nodemon npm 顺序启动脚本
nodemon npm sequential start scripts
我的 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"
},
但是在执行我的第一个脚本后girlsTypeInsert.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] clean exit - waiting for changes before restart
我需要更改什么才能开始我的下一个脚本 app.js?
你应该替换这个
config/referenceBooks/girlsTypeInsert.js && src/app.js"
至
--exec \"config/referenceBooks/girlsTypeInsert.js && src/app.js\""
我的 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"
},
但是在执行我的第一个脚本后girlsTypeInsert.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] clean exit - waiting for changes before restart
我需要更改什么才能开始我的下一个脚本 app.js?
你应该替换这个
config/referenceBooks/girlsTypeInsert.js && src/app.js"
至
--exec \"config/referenceBooks/girlsTypeInsert.js && src/app.js\""