【问题标题】:nodemon npm sequential start scriptsnodemon npm 顺序启动脚本
【发布时间】:2018-12-28 04:06:45
【问题描述】:

我的 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] 干净退出 - 重启前等待更改

启动下一个脚本 app.js 需要更改什么?

【问题讨论】:

标签: node.js nodemon


【解决方案1】:

你应该替换这个

config/referenceBooks/girlsTypeInsert.js && src/app.js"

--exec \"config/referenceBooks/girlsTypeInsert.js && src/app.js\""

【讨论】:

    猜你喜欢
    • 2016-08-18
    • 2019-09-26
    • 2018-07-12
    • 2017-01-03
    • 2018-01-29
    • 1970-01-01
    • 2019-04-13
    • 2016-02-26
    • 2017-05-10
    相关资源
    最近更新 更多