nodemon not found in npm

前端 未结 29 1187
终归单人心
终归单人心 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:55

    npx nodemon (app.js) worked for me and nodemon (app.js) did not.

    I updated node.js to the latest version and now both are working.

    0 讨论(0)
  • 2020-12-24 10:55

    I my case:

    npm install nodemon
    

    With out any flags etc.

    0 讨论(0)
  • 2020-12-24 10:57

    You have to simply installed it globally. npm install -g nodemon

    0 讨论(0)
  • 2020-12-24 10:57

    This worked for me ...

    Install nodemon as a local dev dependency

    npm install --save-dev nodemon
    

    Add script to your application package.json to start the application.

    "scripts": {
      "start": "nodemon app.js"
    },
    

    Start nodemon with npm start

    $ npm start
    
    > node-rest-demo@1.0.0 start node-rest-demo
    > nodemon app.js
    
    [nodemon] 1.19.4 [nodemon] to restart at any time, enter `rs` [nodemon] watching dir(s): *.* [nodemon] watching extensions: js,mjs,json [nodemon] starting `node app.js` Starting server ...
    
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-24 10:59

    Instructions for Windows,

    Open Command Prompt.
    type npm i -g nodemon --save
    "--save" is to save the addition of this node package in your project's package.json file

    0 讨论(0)
提交回复
热议问题