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

Module not found: Error: Can't resolve 'p-queue' after updating to 7.1.0 #145

Closed
rakhadkz opened this issue May 12, 2021 · 13 comments
Closed

Comments

@rakhadkz
Copy link

6.6.2 => 7.1.0
I've found a pretty similar issue title before, but that one was related to react-scripts start command
It works with the previous Major version. I moved to ESM (replaced requied() to import). Any ideas?

node version 14.x
p-queue 7.1.0

using webpack-dev-server (^3.11.1)

@sindresorhus
Copy link
Owner

This is not the place to ask for support regarding Webpack or webpack-dev-server. This package works fine with plain Node.js. I would open an issue on Webpack or webpack-dev-server asking for help there.

@CristoMonte
Copy link

I have the same problem with parcel on version 7.1.0, but it works fine with version 6.6.2.

@sanwar-oc
Copy link

I also have the same problem with 7.1.0 with webpack build. I'm downgrading to 6.6.2.

@bjornlll
Copy link

bjornlll commented May 30, 2021

I had the same issue with an expo init-generated React Native app (using Facebook's Metro Bundler, not webpack).

Thanks for the tip! Downgrading to 6.6.2 solved it for me.

@skjnldsv
Copy link

skjnldsv commented Jun 1, 2021

@sindresorhus this is an issue with this lib.
Importing with import PQueue from 'p-queue' just fails. Webpack cannot find your export path (latest webpack5, using tons of other esm import and they all work fine)

@JamesGarbaczewski
Copy link

Ran into the same issue. Importing
import PQueue from 'p-queue/dist';
worked

@tlgimenes
Copy link

I'm having the same problem in here and I think this isn't a problem with this library. I think, however, for compatibility reasons, a "module" field is missing on this lib's package.json so tools like tsdx (that uses rollup) can work fine.

@okbeng03
Copy link

okbeng03 commented Sep 7, 2021

Ran into the same issue. Importing
import PQueue from 'p-queue/dist';
worked

The error maybe package not export main entry point

I'm try local, add the main define , it works

Frans-L added a commit to Frans-L/p-queue that referenced this issue Apr 27, 2022
Fixes the issue: sindresorhus#145

A similar issue and fix can be found from instance here: uuidjs/uuid#449
karrui added a commit to opengovsg/FormSG that referenced this issue Jun 2, 2022
st3iny added a commit to nextcloud/contacts that referenced this issue Jul 12, 2022
Ref sindresorhus/p-queue#145 (comment)

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
@kitsunde
Copy link

kitsunde commented May 28, 2023

It indeed runs just fine with plain javascript.

Another issue is that it confuses eslint-plugin-import on import/no-unresolved. Which does resolve when it's p-queue/dist however .esm won't import on that.

This isn't the case with p-all, p-map, or p-throttle, not sure what's different in this module, but my project is only partially esm and it's only maintained for pure esm projects.

@mifi
Copy link

mifi commented Jul 12, 2023

Doing some research, it seems that p-queue is different from Sindre's other p-* modules in that p-queue has a build step and exports ./dist/index.js:

"exports": "./dist/index.js",

Meanwhile the other packages don't have a build step but instead "exports": "./index.js", directly:

I'm guessing that webpack and other bundlers, when they don't find a main field, they will fallback to using the default index.js, (see specification here). For all the other packages, this is fine because the file is indeed stored at ./index.js, however for p-queue, the file is stored in ./dist/index.js. Not sure why webpack (and other bundlers) are ignoring the exports directive though. Could be a bug or ambiguity in the specifications. Maybe the projects using p-queue needs to have "type": "module" set?

@kolyasya
Copy link

kolyasya commented Jan 5, 2024

import PQueue from 'p-queue/dist'; worked for me in Meteor app.

This should be documented somehow 🤔

@joao-furtado-SADA
Copy link

joao-furtado-SADA commented Feb 27, 2024

After wasting hours of my life looking for a solution to this, the only thing that comes to my mind is:

Why the hell JS/TS cannot simply WORK?

I love TS, but it's impressive how you just waste a ton of time chasing around zero-value env-related issues because someone decided that ESM was a good idea.

Sorry for the rant

Back to work

@lightrow
Copy link

lightrow commented Jul 17, 2024

import PQueue from 'p-queue/dist' no longer works when moduleResolution is NOT set to "Node" (Node16) with react native 0.74

Ok it works, you just need to redeclare the types

// esm.d.ts

declare module 'p-queue/dist' {
    export * from 'p-queue';
    export { default } from 'p-queue';
}

declare module 'p-memoize/dist' {
    export * from 'p-memoize';
    export { default } from 'p-memoize';
}

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