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

np error ERR_REQUIRE_ESM #712

Closed
dimaskc opened this issue Sep 4, 2023 · 2 comments
Closed

np error ERR_REQUIRE_ESM #712

dimaskc opened this issue Sep 4, 2023 · 2 comments

Comments

@dimaskc
Copy link

dimaskc commented Sep 4, 2023

Nothing weird, just normal installation guide on readme

Description

After i install np, and run, it returns error:

/Users/dimas/.nvm/versions/node/v18.17.1/lib/node_modules/np/node_modules/import-local/index.js:23
        return !filenameInLocalNodeModules && localFile && path.relative(localFile, normalizedFilename) !== '' && require(localFile);
                                                                                                           ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/dimas/Acode/web/knowledgecatalyst/afap/node_modules/.pnpm/np@8.0.4/node_modules/np/source/cli.js from /Users/dimas/.nvm/versions/node/v18.17.1/lib/node_modules/np/node_modules/import-local/index.js not supported.
Instead change the require of cli.js in /Users/dimas/.nvm/versions/node/v18.17.1/lib/node_modules/np/node_modules/import-local/index.js to a dynamic import() which is available in all CommonJS modules.
    at module.exports (/Users/dimas/.nvm/versions/node/v18.17.1/lib/node_modules/np/node_modules/import-local/index.js:23:108)
    at file:///Users/dimas/.nvm/versions/node/v18.17.1/lib/node_modules/np/source/cli.js:11:6 {
  code: 'ERR_REQUIRE_ESM'
}

Steps to reproduce

  1. npm install --global np
  2. np
  3. <>

Expected behavior

It should showing upgrade menu like this
image

Environment

np - 8.0.4
Node.js - 18.17.1
npm - 9.6.7
Git - 2.39.2
OS - MAC OS Ventura (intel chip)

@tommy-mitchell
Copy link
Collaborator

tommy-mitchell commented Sep 4, 2023

Your globally installed version of np is older than your locally installed one, I believe.


Edit: actually @sindresorhus, does import-local need updating? It’s still CJS.


Edit 2: never mind, looking closer we’re already passing import.meta.url to it.

@dimaskc
Copy link
Author

dimaskc commented Sep 5, 2023

I'm sure that both versions are match.

Global
telegram-cloud-photo-size-5-6321094839621498361-x

Locally installed
image

But thanks for your answer, I ended up uninstalling the local np and use the global one.

@dimaskc dimaskc closed this as completed Sep 5, 2023
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

2 participants