Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodemon 2.0.17 not starting and showing require error #2030

Closed
Rishikant181 opened this issue Jun 23, 2022 · 5 comments
Closed

nodemon 2.0.17 not starting and showing require error #2030

Rishikant181 opened this issue Jun 23, 2022 · 5 comments

Comments

@Rishikant181
Copy link

Rishikant181 commented Jun 23, 2022

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
Copy link
Contributor

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
Copy link

caiokawasaki commented Jun 23, 2022

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
Copy link
Owner

remy commented Jun 23, 2022

dupe of #2031 - will track there.

@remy remy closed this as completed Jun 23, 2022
@DanSuthWMW
Copy link

Downgrading to nodemon 2.0.14 resolved for me in the meantime

@remy
Copy link
Owner

remy commented Jun 23, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants