remy / nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development
http://nodemon.io/
MIT License
26.35k stars 1.74k forks source link

Nodemon restart process looks for tempfile.js~ and throws an error. #2215

Closed theTutorB closed 3 weeks ago

theTutorB commented 3 months ago

Expected behaviour

When nodemon detects a change in the codebase under watch, it should reload the file that the changes occurred on, and restart the process without issue, with all changes that don't throw errors to load and restart the server application as expected.

Actual behaviour

  1. When nodemon detecs a change, it attempts to find the filename.js~ and not the actual file filename.js.
  2. nodemon throws an error:
    {
    "errno": -2,
    "code": "ENOENT",
    "syscall": "stat",
    "path": "/absolute/path/to/project/filename.js~"
    "stack": "Error: ENOENT: no such file or directory, stat      '/absolute/path/to/project/filename.js~'"
    "message": "ENOENT: no such file or directory, stat '/absolute/path/to/project/filename.js~'"
    }
  3. Process fails with error

Steps to reproduce

  1. start application using nodemon
  2. make change to file under watch
  3. observe nodemon attmpt to locate file that is temp file and crash with output above.

please see attached

Screen_Shot_2024-08-12_at_10_04_36_AM

any and all support is greatly appreciated!


additional info:

When I run our api locally with npm run start this script gets called:

"start": "./node_modules/.bin/nodemon --config nodemon.json --exec ./node_modules/.bin/babel-node src/server.js", so far all of this worked just fine without issue, beautiful dev experience... then somewhere I broke it with an update to nodemon i'm sure.

And now whenever I make a change to any file being watched (i.e. I set it to filename.js~ in this case) that nodemon picks up on and attempts to restart the process I get an error every single time...

{ "errno": -2, "code": "ENOENT", "syscall": "stat", "path": "/absolute/path/to/project/filename.js~" "stack": "Error: ENOENT: no such file or directory, stat '/absolute/path/to/project/filename.js~'" "message": "ENOENT: no such file or directory, stat '/absolute/path/to/project/filename.js~'" } From the research I have been doing it seems like the ENOENT error is occurring because nodemon is trying to watch a backup file (e.g., filename.js~) that does not exist.

I tried updating the nodemon.json config file as well, see below:

{ "ignore": [ "node_modules/", "*.test.js", "dist/", "seed/", "reports/", "logs/", "swagger.json", "*/.js~" ], "watch": ["src/"], "verbose": true } Not sure how to resolve this issue, and have been dealing with it for a while, but have not been able to figure out what exactly is going on with my timeboxed troubleshooting approach. So hopefully I can get some feedback from the community!


If applicable, please append the --dump flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.

github-actions[bot] commented 3 months ago

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. Thank you for contributing <3

Muhammad-Owais-Warsi commented 2 months ago

In my package.json I have added the following script "dev":"nodemon --watch index.js"
After then I started my applicaton and made changes to the file. I didn't got any error. Let me know if I have misunderstood something.

github-actions[bot] commented 1 month ago

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. Thank you for contributing <3

github-actions[bot] commented 3 weeks ago

Automatically closing this issue due to lack of activity