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

Support lost for Node 16 / CommonJs #63

Closed
pp0rtal opened this issue Jun 15, 2022 · 1 comment
Closed

Support lost for Node 16 / CommonJs #63

pp0rtal opened this issue Jun 15, 2022 · 1 comment

Comments

@pp0rtal
Copy link

pp0rtal commented Jun 15, 2022

Hello,
I was running p-limit@3 and tried to upgrade to p-limit@4

Reproduce error

  test cat package.json 
{
  "dependencies": {
    "p-limit": "^4.0.0"
  }
}

My program is in Typescript and I'm compiling to use CommonJS native ("module": "commonjs", in my tsconfig)

  test cat index.js 
const pLimit = require("p-limit")

console.log(pLimit)

resulting to an error at runtime

  test node index.js 
/home/portal/test/index.js:1
const pLimit = require("p-limit")
               ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/portal/test/node_modules/p-limit/index.js from /home/portal/test/index.js not supported.
Instead change the require of /home/portal/test/node_modules/p-limit/index.js in /home/portal/test/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/portal/test/index.js:1:16) {
  code: 'ERR_REQUIRE_ESM'
}

With 3.x

program is working

  test node .          
[Function: pLimit]

Is the support lost, or am I using the lib wrongly?

@pp0rtal
Copy link
Author

pp0rtal commented Jun 15, 2022

Project has became ESM only so we have to stay at 3 major version when using require

@pp0rtal pp0rtal closed this as completed Jun 15, 2022
elenatanasoiu added a commit to github/vscode-codeql that referenced this issue Oct 12, 2022
Version 4.0 has dropped support for Node 16 / CommonJS so we'd have to
first upgrade to ESM before we could use a newer version of this package.

This would involve updating package.json with:
{
  "type": "module"
}

For now let's use the package that just works. We can think of upgrading as
a separate issue.

See:
- sindresorhus/p-limit#63
- https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
- sindresorhus/p-limit#57
elenatanasoiu added a commit to github/vscode-codeql that referenced this issue Oct 13, 2022
Version 4.0 has dropped support for Node 16 / CommonJS so we'd have to
first upgrade to ESM before we could use a newer version of this package.

This would involve updating package.json with:
{
  "type": "module"
}

For now let's use the package that just works. We can think of upgrading as
a separate issue.

See:
- sindresorhus/p-limit#63
- https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
- sindresorhus/p-limit#57
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

1 participant