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

nodemon 2.0.17 not starting and showing require error #2030

Closed Rishikant181 closed 2 years ago

Rishikant181 commented 2 years ago

Here is the error shown when I start nodemon

npm WARN exec The following package was not found and will be installed: nodemon@2.0.17 2:40:33 PM - Found 0 errors. Watching for file changes. /root/.npm/_npx/c08057651e53e122/node_modules/nodemon/bin/nodemon.js:15 require('update-notifier')({ pkg }).notify(); ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /root/.npm/_npx/c08057651e53e122/node_modules/update-notifier/index.js from /root/.npm/_npx/c08057651e53e122/node_modules/nodemon/bin/nodemon.js not supported. rettiwt-api-1 | [1] Instead change the require of index.js in /root/.npm/_npx/c08057651e53e122/node_modules/nodemon/bin/nodemon.js to a dynamic import() which is available in all CommonJS modules. at Object. (/root/.npm/_npx/c08057651e53e122/node_modules/nodemon/bin/nodemon.js:15:3) { code: 'ERR_REQUIRE_ESM' }

Node.js v18.4.0

I am not using a local nodemon installation, but using npx to use it

elrumordelaluz commented 2 years ago

Oops, seems that we opened two related on the same issue at the same time :)

Linking here #2031 in case the other details could be useful.

caiokawasaki commented 2 years ago

Same here

internal/modules/cjs/loader.js:1080
       throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
       ^

 Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /usr/local/lib/node_modules/nodemon/node_modules/update-notifier/index.js
 require() of ES modules is not supported.
     require() of /usr/local/lib/node_modules/nodemon/node_modules/update-notifier/index.js from /usr/local/lib/node_modules/nodemon/bin/nodemon.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
     Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /usr/local/lib/node_modules/nodemon/node_modules/update-notifier/package.json.

     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1080:13)
     at Module.load (internal/modules/cjs/loader.js:928:32)
     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
     at Module.require (internal/modules/cjs/loader.js:952:19)
     at require (internal/modules/cjs/helpers.js:88:18)
     at Object.<anonymous> (/usr/local/lib/node_modules/nodemon/bin/nodemon.js:15:3)
         at Module._compile (internal/modules/cjs/loader.js:1063:30)
    defines all .js files in that package scope as ES modules.
     Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /usr/local/lib/node_modules/nodemon/node_modules/update-notifier/package.json.

         at Object.Module._extensions..js (internal/modules/cjs/loader.js:1080:13)
         at Module.load (internal/modules/cjs/loader.js:928:32)
         at Function.Module._load (internal/modules/cjs/loader.js:769:14)
         at Module.require (internal/modules/cjs/loader.js:952:19)
         at require (internal/modules/cjs/helpers.js:88:18)
         at Object.<anonymous> (/usr/local/lib/node_modules/nodemon/bin/nodemon.js:15:3)
             at Module._compile (internal/modules/cjs/loader.js:1063:30)
             at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
             at Module.load (internal/modules/cjs/loader.js:928:32)
             at Function.Module._load (internal/modules/cjs/loader.js:769:14) {
               code: 'ERR_REQUIRE_ESM'
             }
remy commented 2 years ago

dupe of https://github.com/remy/nodemon/issues/2031 - will track there.

DanSuthWMW commented 2 years ago

Downgrading to nodemon 2.0.14 resolved for me in the meantime

remy commented 2 years ago

2.0.18 is available now - goes back to update-notifier@5.x