local-pkg icon indicating copy to clipboard operation
local-pkg copied to clipboard

Yarn PnP support

Open NMinhNguyen opened this issue 3 years ago • 5 comments

I'm trying to use Vitest and I'm running into an issue with Yarn PnP:

.pnp.cjs:101340 Uncaught Error: local-pkg tried to access vite, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: vite (via "vite/package.json") Required by: local-pkg@npm:0.4.0 (via /Users/minh/dev/project/.yarn/cache/local-pkg-npm-0.4.0-c31827f33b-46964cea4b.zip/node_modules/local-pkg/)

I believe that this package needs to support basedir (similar to resolve), and set the paths option of require.resolve:

https://github.com/antfu/local-pkg/blob/fc9d06c5a43485d83f41ec35dfc842e1f6d45aa5/index.mjs#L51-L65

NMinhNguyen avatar Jan 04 '22 17:01 NMinhNguyen

Yes this is still an issue. Is there an easy fix for this?

TeemuKoivisto avatar Nov 22 '22 16:11 TeemuKoivisto

bump

sirganya avatar Dec 20 '22 06:12 sirganya

This also happens with pnpm: https://github.com/vitest-dev/vitest/issues/3112.

JoshuaKGoldberg avatar Apr 29 '23 22:04 JoshuaKGoldberg

bump

francoisauclair911 avatar Mar 15 '24 20:03 francoisauclair911

FYI - Vitest no longer uses local-pkg as of version 2.0.0, and therefore, PnP issues are also gone.

wojtekmaj avatar Jul 08 '24 12:07 wojtekmaj