nodejs问题

  1. yarn add express-generator global
    然后再express myapp报错bash: express: command not found
    npm install express-generator -g 然后express myapp就没问题
    2.express框架,每次修改代码之后,都需要重新npm start 才能看到改动的效果
    安装nodemon,node.js应用有任何改动自动重启服务,
    文档:https://github.com/remy/nodemon
    npm install -g nodemon或npm install --save-dev nodemon
    运行 nodemon --exec npm start

配置nodemon.json

{
    "restartable": "rs",
    "ignore": [
        ".git",
        "node_modules/**/node_modules"
    ],
    "delay": "1500",
    "verbose": true,
    "execMap": {
        "js": "node --harmony"
    },
    "events": {
        "restart": "osascript -e 'display notification \"App restarted due to:\n'$FILENAME'\" with title \"nodemon\"'"
    },
    "watch": [
    ],
    "env": {
        "NODE_ENV": "development"
    },
    "ext": "js,json"
}

你可能感兴趣的:(nodejs问题)