sindresorhus / p-limit

Run multiple promise-returning & async functions with limited concurrency
MIT License
2.04k stars 106 forks source link

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

Closed hamzaafridi closed 3 years ago

hamzaafridi commented 3 years ago

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 commented 3 years ago

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

Yengas commented 2 years ago

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