[BUG] Fail to import from typescript files in package type module
See original GitHub issueContext:
- 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:
- Created a year ago
- Comments:6 (4 by maintainers)
Top 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 >
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 also have this problem, in particular since updating from 1.19.1 to 1.21.1.
Got it; thanks for your time! So, I’ll close the issue on that point