nodemon not found in npm

前端 未结 29 1448
终归单人心
终归单人心 2020-12-24 10:17

I have a problem: nodemon does not run off the npm script (e.g. npm start),
but if nodemon is called on the command line outside the npm script, nodemon run

29条回答
  •  旧巷少年郎
    2020-12-24 10:59

    heroku runs in a production environment by default so it does not install the dev dependencies.

    if you don't want to reinstall nodemon as a dependency which I think shouldn't because its right place is in devDependencies not in dependencies.

    instead, you can create two npm script to avoid this error by running nodemon only in your localhost like that:

    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "node app.js",
        "start:dev": "nodemon --watch"
    },
    

    and when you want to run the project locally just run in your terminal npm run start:dev and it will load app.js by nodemon.

    while in heroku npm start runs by default and load app.js from a normal node command and you get rid of that error.

提交回复
热议问题