[BUG] "Cannot import a typescript file from an esmodule"
See original GitHub issueContext:
- Playwright Version: [1.20.1]
- Operating System: [ Mac] System: OS: macOS 12.3 Memory: 115.30 MB / 16.00 GB Binaries: Node: 15.14.0 - ~/.nvm/versions/node/v15.14.0/bin/node npm: 6.14.13 - ~/.nvm/versions/node/v15.14.0/bin/npm Languages: Bash: 3.2.57 - /bin/bash
Describe the bug
Getting Cannot import a typescript file from an esmodule when running npx playwright test
This issue only happens on version 1.20.1. I fix it by going back to version 1.20.0
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Typescript: Cannot use import statement outside a module
The error means Node found an import statement in a file that it does not consider an ECMAScript (ES) module. Adding "type": "module"...
Read more >Documentation - ECMAScript Modules in Node.js - TypeScript
When a file is considered an ES module, a few different rules come into play compared to CommonJS: import / export statements and...
Read more >How we employed the new ECMAScript Module Support in ...
That being said, with TS we could use import even on commonJS mode. ... file is being treated as an ES module because...
Read more >JavaScript modules - MDN Web Docs
You cannot change the variable that was imported, but you can ... Note that you could solve the problem in the module files...
Read more >node-fetch Error [ERR_REQUIRE_ESM]: require() of ES ...
To solve the node-fetch error [ERR_REQUIRE_ESM]: require() of ES Module not supported, use a dynamic import to import the `node-fetch` package or downgrade ......
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 created a new project using
npm init svelteand I’m still getting this error when running the test command, despite the playwright version being 1.22.2npm run test does not work… error with playwright REPRODUCING STEPS: npm init svelte (choose Typescript, choose Demo App) npm run test