sindresorhus / p-queue

Promise queue with concurrency control
MIT License
3.39k stars 182 forks source link

Module not found: Can't resolve 'p-queue' in xxx at `7.3.0` #165

Closed tkforce closed 2 years ago

tkforce commented 2 years ago

I'm currently using the latest version 7.3.0, however when I import with

import PQueue from 'p-queue'

I'll get the following error:

image

But when I imported with additional /dist

import PQueue from 'p-queue/dist'

It will works as expected! (might have sth to do with the default export?)

sindresorhus commented 2 years ago

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

olivergeorge commented 1 year ago

Just a heads up that this was a problem for us. We had compatibilities problems with StorybookJS and ShadowCLJS.

Things started working again once we added "main" to the package.json pointing at the same dist index file. That fixed both.

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

An alternative with ShadowCLJS was to configure around the problem: https://shadow-cljs.github.io/docs/UsersGuide.html#js-entry-keys

I'm not good enough friends with storybookjs to work out what configuration might help.

Perhaps there's good reasons not to add "main" to the package.json. If it's a matter of taste, perhaps it would be a kindness to expand compatibility by adding a "main" entry point.

In terms of empathising with users, for us it would be a big and disruptive change to update all tooling right now.

Thanks for your hard work.

akinnee commented 1 year ago

eslint was complaining:

error  Unable to resolve path to module 'p-queue'  import/no-unresolved

which went away when switching from:

import PQueue from 'p-queue';

to:

import PQueue from 'p-queue/dist';

I think it's because the package.json for this package is missing a main property.