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] Fail to import from typescript files in package type module

See original GitHub issue

Context:

  • Playwright Version: 1.22.0-alpha-may-10-2022
  • Operating System: MacOS
  • Node.js version: v17.9.0
  • Browser: Not applicable

Describe the bug

There is a problem with importing from Typescript files with "type": "module" in the package.json file. When I try to import something to a test file, I get the following error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/playwright-bug/test/testDependency' imported from    ####/playwright-bug/test/test.test.ts

I’ve created a repository that represents the configuration of my project and where is possible to reproduce the issue by run the command pnpm test - https://github.com/GenrikhFetischev/playwright-bug-report

Additional info When I try to import with a file extension like there import work. Without "type": "module" in package.json imports work

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
pierscowburncommented, May 10, 2022

I also have this problem, in particular since updating from 1.19.1 to 1.21.1.

0reactions
GenrikhFetischevcommented, May 21, 2022

Got it; thanks for your time! So, I’ll close the issue on that point

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common TypeScript module problems and how to solve them
Solution 2: Locate the module and resolve imports​​ ts . This will allow the module to be found.
Read more >
TypeScript ES6 import module "File is not a module error"
For this pattern to work, it's important that the symbol defined via import is only used in type positions (i.e. never in a...
Read more >
TypeScript: Cannot use import statement outside a module
To solve the error "Cannot use import statement outside a module" in TypeScript, set the module option to commonjs in your tsconfig.json file...
Read more >
TSConfig Reference - Docs on every TSConfig option
An error occurs if any of the files can't be found. ... depending on the file extension and the value of the type...
Read more >
Common Error Details - Snowpack
If you are using TypeScript, this error could occur if you are importing or exporting something that only exists in TypeScript (like a...
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