We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1df2991 commit 574cc7dCopy full SHA for 574cc7d
packages/vitest/src/node/pkg.ts
@@ -1,4 +1,5 @@
1
import url from 'node:url'
2
+import { createRequire } from 'node:module'
3
import c from 'picocolors'
4
import { isPackageExists } from 'local-pkg'
5
import { EXIT_CODE_RESTART } from '../constants'
@@ -10,6 +11,16 @@ export async function ensurePackageInstalled(
10
11
dependency: string,
12
root: string,
13
) {
14
+ if (process.versions.pnp) {
15
+ const targetRequire = createRequire(__dirname)
16
+ try {
17
+ targetRequire.resolve(dependency, { paths: [root, __dirname] })
18
+ return true
19
+ }
20
+ catch (error) {
21
22
23
+
24
if (isPackageExists(dependency, { paths: [root, __dirname] }))
25
return true
26
0 commit comments