playwright
playwright copied to clipboard
[BUG] Playwright with Yarn and type: module causes ENOTDIR
Context:
- Playwright Version: Version 1.24.2
- Operating System: Linux
- Node.js version: v18.3.0
- Browser: Not Applicable (any)
Reproduction Create project with:
yarn set version stable
yarn create playwright
At this point, running yarn run playwright test
will succeed!
However, adding "type": "module"
in the package.json
will cause things to break with this error:
node:fs:1587
handleErrorFromBinding(ctx);
^
Error: ENOTDIR: not a directory, stat `[path]/.yarn/cache/@playwright-test-npm-1.24.2-efa86d5947-3d24ae5957.zip/node_modules/@playwright/test/lib/experimentalLoader.js'
at statSync (node:fs:1587:3)
at tryStatSync (node:internal/modules/esm/resolve:165:13)
at finalizeResolution (node:internal/modules/esm/resolve:398:17)
at moduleResolve (node:internal/modules/esm/resolve:966:10)
at defaultResolve (node:internal/modules/esm/resolve:1174:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)
at ESMLoader.import (node:internal/modules/esm/loader:404:22)
at initializeLoader (node:internal/process/esm_loader:71:49)
at loadESM (node:internal/process/esm_loader:84:11) {
errno: -20,
syscall: 'stat',
code: 'ENOTDIR',
path: '[path]/.yarn/cache/@playwright-test-npm-1.24.2-efa86d5947-3d24ae5957.zip/node_modules/@playwright/test/lib/experimentalLoader.js'
}
Node.js v18.3.0
I seemingly have to add "type": "module"
in order to run an unrelated package written using ESModules but it seems like the experimentalLoader
is causing issues. I poked into the source to figure out what's going on and it seems to be happening in cli.js
when NODE_OPTIONS
is being set. I tried fixing it by setting PW_DISABLE_TS_ESM
and PW_TS_ESM_ON
but this simply made .ts
files unusable as one might expect.
My guess is that the --experimental-loader
flag doesn't play nice with the .pnp.cjs
loader that recognizes how to deal with Plug'n'Play.
Encountering this error as well when using type: module with Yarn 3.2.2
Wasn't fixed by upgrading to 1.25.1