-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[BUG] Unknown file extension ".ts" on fresh init when adding "type": "module"
#18282
Comments
"type": "module"
Works for me - I can't repro! Can you make sure that you use Node.js 16+? I saw you wrote that you are using a recent one, but type: module support is only supported in Playwright in 16+. |
My node version is 16.5.0 so that should be fine right? |
It actually needs to be a more recent one, like v16.18.0. |
Okay, I'll update node and try that again when I have a chance. Thank you! I'll close this issue. |
I got this error in a monorepo where the package with TS tests had Setting I don't have non |
I'm also seeing this error on a monorepo project. The packages with the test files are marked with It would be nice if Playwright implemented a flag or something to force it to run as ESM even without The workaround I found was running playwright with an ESM loader (make sure to install NODE_OPTIONS=--loader=esm-loader-typescript playwright test |
In order to properly run Playwright tests in this monorepo, I had to set "type": "module" in the root `packge.json`. Without that I was getting an error saying that the ".ts" was an unknown file extension. This answer tipped-me off on this solution: microsoft/playwright#18282 (comment) For these initial Playwright tests, I created a temporary dummy page and added a ".e2e.ts" file that is associated with that file.
Any update on this one? This is still an issue... and I'm not sure what is the recommended workaround for that. |
If you still have this problem, try to add I had simple project, I didn't need complex configuration, so I skipped config file (as far as I know it is not required), but was getting Then added empty If you have monorepo, every project needs to have own config file. |
Why is this closed? At least update the documentation for install to include that a monorepo will require use of |
Context:
System:
Binaries:
Languages:
Code Snippet
N/A
Describe the bug
In a completely empty directory I ran
npm init playwright@latest
, and choseThen I ran
npx playwright test
and everything ran correctly.Then I added
"type": "module"
to my package.json and rannpx playwright test
again.Received this error
The text was updated successfully, but these errors were encountered: