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] "Cannot import a typescript file from an esmodule"

See original GitHub issue

Context:

  • 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:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
khaki32commented, Jun 10, 2022

I created a new project using npm init svelte and I’m still getting this error when running the test command, despite the playwright version being 1.22.2

1reaction
regnoucommented, Jun 15, 2022

npm run test does not work… error with playwright REPRODUCING STEPS: npm init svelte (choose Typescript, choose Demo App) npm run test

Read more comments on GitHub >

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

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