sindresorhus / np

A better `npm publish`
MIT License
7.56k stars 299 forks source link

Cannot run `np` globally on Node.js v20.12.2 #747

Open mesqueeb opened 5 months ago

mesqueeb commented 5 months ago

executing my global np while being in a directory that also has np installed locally.

/usr/local/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/empidornis/ghq/github.com/mesqueeb/FuegoOnAppleSilicon/node_modules/np/source/cli.js from /usr/local/lib/node_modules/np/node_modules/import-local/index.js not supported.
Instead change the require of cli.js in /usr/local/lib/node_modules/np/node_modules/import-local/index.js to a dynamic import() which is available in all CommonJS modules.
    at module.exports (/usr/local/lib/node_modules/np/node_modules/import-local/index.js:23:108)
    at file:///usr/local/lib/node_modules/np/source/cli.js:9:6 {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v20.12.2