[BUG] Unknown file extension ".ts" on fresh init when adding `"type": "module"`
See original GitHub issueContext:
- Playwright Version: 1.27.1
- Operating System: Mac
- Node.js version: 16.5.0
- Browser: N/A
- Extra: N/A
System:
- OS: macOS 12.6
- Memory: 89.59 MB / 16.00 GB
Binaries:
- Node: 16.5.0 - ~/.nvm/versions/node/v16.5.0/bin/node
- npm: 8.3.0 - ~/.nvm/versions/node/v16.5.0/bin/npm
Languages:
- Bash: 3.2.57 - /bin/bash
Code Snippet
N/A
Describe the bug
In a completely empty directory I ran npm init playwright@latest
, and chose
✔ Do you want to use TypeScript or JavaScript? · TypeScript
✔ Where to put your end-to-end tests? · tests
✔ Add a GitHub Actions workflow? (y/N) · false
✔ Install Playwright browsers (can be done manually via 'npx playwright install')? (Y/n) · false
Then I ran npx playwright test
and everything ran correctly.
Then I added "type": "module"
to my package.json and ran npx playwright test
again.
Received this error
TypeError: Unknown file extension ".ts" for /Users/my-name/Development/playwright-ts-bug/playwright.config.ts
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Can't run my Node.js Typescript project TypeError ...
Can't run my Node.js Typescript project TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /app/src/App.ts · Ask Question.
Read more >unknown file extension ".ts" type module - You.com
this issue happens when you add "type": "module", in package.json file while working with node typescript. Open side panel.
Read more >Error when trying to use Typescript with Express - Reddit
You should just skip the file extension completely. TypeScript will prefer .ts on compile time module resolution and node will prefer .js on ......
Read more >Documentation - ECMAScript Modules in Node.js - TypeScript
ts file in package, whether it is treated as an ESM or CommonJS file is based on the containing package. New File Extensions....
Read more >rollup.js
If you want to write your configuration as a CommonJS module using require and module.exports , you should change the file extension to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I got this error in a monorepo where the package with TS tests had
"type": "module",
and playwright was installed in the root.Setting
"type": "module",
in the root as well fixed the problem.I don’t have non
"type": "module",
packages, so take it with a grain of salt.Okay, I’ll update node and try that again when I have a chance. Thank you! I’ll close this issue.