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.13k stars 1.72k forks source link

Cannot read properties of undefined (reading 'filename') in Node v20.6.0 (yarn2) #2142

Closed louisbrulenaudet closed 6 months ago

louisbrulenaudet commented 8 months ago

It seems like nodemon doesn't work in Node 20.6.0 :

I have the following error : .yarn/unplugged/nodemon-npm-3.0.1-07d6d759b1/node_modules/nodemon/lib/version.js:17 var promise = findPackage(path.dirname(module.parent.filename)) ^ TypeError: Cannot read properties of undefined (reading 'filename') at version (/Users/louisbrulenaudet/Desktop/Node.js - Site internet/.yarn/unplugged/nodemon-npm-3.0.1-07d6d759b1/node_modules/nodemon/lib/version.js:17:56) at pin (/Users/louisbrulenaudet/Desktop/Node.js - Site internet/.yarn/unplugged/nodemon-npm-3.0.1-07d6d759b1/node_modules/nodemon/lib/version.js:10:10) at /Users/louisbrulenaudet/Desktop/Node.js - Site internet/.yarn/unplugged/nodemon-npm-3.0.1-07d6d759b1/node_modules/nodemon/lib/config/index.js:81:5 at normaliseRules (/Users/louisbrulenaudet/Desktop/Node.js - Site internet/.yarn/unplugged/nodemon-npm-3.0.1-07d6d759b1/node_modules/nodemon/lib/config/load.js:125:3) at ready (/Users/louisbrulenaudet/Desktop/Node.js - Site internet/.yarn/unplugged/nodemon-npm-3.0.1-07d6d759b1/node_modules/nodemon/lib/config/load.js:108:9) at /Users/louisbrulenaudet/Desktop/Node.js - Site internet/.yarn/unplugged/nodemon-npm-3.0.1-07d6d759b1/node_modules/nodemon/lib/config/load.js:111:7 at callback (/Users/louisbrulenaudet/Desktop/Node.js - Site internet/.yarn/unplugged/nodemon-npm-3.0.1-07d6d759b1/node_modules/nodemon/lib/config/load.js:143:5) at /Users/louisbrulenaudet/Desktop/Node.js - Site internet/.yarn/unplugged/nodemon-npm-3.0.1-07d6d759b1/node_modules/nodemon/lib/config/load.js:196:5 at callback (/Users/louisbrulenaudet/Desktop/Node.js - Site internet/.yarn/unplugged/nodemon-npm-3.0.1-07d6d759b1/node_modules/nodemon/lib/config/load.js:143:5) at /Users/louisbrulenaudet/Desktop/Node.js - Site internet/.yarn/unplugged/nodemon-npm-3.0.1-07d6d759b1/node_modules/nodemon/lib/config/load.js:183:5

Node.js v20.6.0

remy commented 8 months ago

Can you confirm how nodemon was invoked?

louisbrulenaudet commented 8 months ago

Dear Remy,

I hope this message finds you well. I sought to emulate the behavior demonstrated in Node version 20.5.1, which involved utilizing the "nodemon" command to execute the "app.js" script within the context of my "start" script ("start": "nodemon app.js") as delineated in the "package.json" file. Additionally, I endeavored to incorporate environmental variables from an ".env" file using the command "nodemon --env-file=.env app.js."

Thank you for your attention to this matter.

Sincerely, Louis

remy commented 8 months ago

I can't replicate. It's going to need more information from you - specifically how to replicate:

~/dev/nodemon/issues/2142$ npm run start

> start
> nodemon app.js

[nodemon] 3.0.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,cjs,json
[nodemon] starting `node app.js`
^C%

~/dev/nodemon/issues/2142$ cat package.json app.js
       │ File: package.json
   1   │ {
   2   │   "scripts": { "start": "nodemon app.js" }
   3   │ }
       │ File: app.js
   1   │ require('http').createServer((req, res) => res.end('ok')).listen(8000);
   2   │

~/dev/nodemon/issues/2142$ node -v
v20.5.1
SCR-20231031-lgdr
github-actions[bot] commented 8 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

aquiles23 commented 7 months ago

i replicated this using yarn2 with ts-node, but with npm, nodemon worked with no issues and i don't know why

github-actions[bot] commented 7 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

github-actions[bot] commented 6 months ago

Automatically closing this issue due to lack of activity