sindresorhus / p-queue

Promise queue with concurrency control
MIT License
3.45k stars 185 forks source link

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module #136

Closed 0x557269656C closed 3 years ago

0x557269656C commented 3 years ago

I was running tests today against p-queue (^7.0.0), but I've been unable to require the module on Node.js.

I can reproduce this using the Node REPL, as follows:

Welcome to Node.js v14.15.4.
> require('p-queue');

Which will yield the following exception:

Uncaught:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /.../node_modules/p-queue/dist/index.js
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1080:13)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at REPL1:1:1
    at Script.runInThisContext (vm.js:133:18)
    at REPLServer.defaultEval (repl.js:484:29)
    at bound (domain.js:413:15)
    at REPLServer.runBound [as eval] (domain.js:424:12) {
  code: 'ERR_REQUIRE_ESM'
}
0x557269656C commented 3 years ago

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