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

Can't require("p-limit") #57

Closed
hamzaafridi opened this issue Oct 14, 2021 · 2 comments
Closed

Can't require("p-limit") #57

hamzaafridi opened this issue Oct 14, 2021 · 2 comments

Comments

@hamzaafridi
Copy link

I am trying to load this module using:
const pLimit = require("p-limit");

However when I do that I get the following error:

import Queue from 'yocto-queue';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1116:16)
at Module._compile (internal/modules/cjs/loader.js:1164:27)
at Object.intercept [as .js] (/home/hamzaafridi/Workspace/app.vetdrive.co/master/node_modules/amdefine/intercept.js:30:12)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at Module.Hook._require.Module.require (/home/hamzaafridi/.npm/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/master/src/server/modules/print.js:2:16)

Can someone please help?

Thanks!

@sindresorhus
Copy link
Owner

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

@Yengas
Copy link

Yengas commented Jan 8, 2022

Summary: You either use ESM in your project or the version 3.x of this library.

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

3 participants