Restart node upon changing a file

后端 未结 8 715
轮回少年
轮回少年 2020-11-28 17:54

For someone who is coming from PHP background the process of killing node and starting it again after every code change, seems very tedious. Is there any flag when starting

8条回答
  •  独厮守ぢ
    2020-11-28 18:30

    Follow the steps:

    1. npm install --save-dev nodemon

    2. Add the following two lines to "script" section of package.json:

    "start": "node ./bin/www",
    "devstart": "nodemon ./bin/www"
    

    as shown below:

    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "node ./bin/www",
        "devstart": "nodemon ./bin/www"
    }
    
    1. npm run devstart

    https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/skeleton_website

提交回复
热议问题