question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Unknown file extension ".ts" on fresh init when adding `"type": "module"`

See original GitHub issue

Context:

  • 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:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
acdcjuniorcommented, Nov 15, 2022

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.

0reactions
pleek91commented, Oct 27, 2022

Okay, I’ll update node and try that again when I have a chance. Thank you! I’ll close this issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found