Module import does not work with Typescript
See original GitHub issueHi @kopiro Thank you for creating an amazing library. I was trying to use it my Typescript application with import SiriWave from 'siriwave';
but I get Cannot find module 'siriwave ts(2307)'.
literally with any compilerOptions.module
variants in tsconfig.ts.
Typescript module resolution gives me the following:
======== Resolving module 'siriwave' from 'c:/Projects/tstest/app.ts'. ========
Explicitly specified module resolution kind: 'NodeJs'.
Loading module 'siriwave' from 'node_modules' folder, target file type 'TypeScript'.
Found 'package.json' at 'c:/Projects/tstest/node_modules/siriwave/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'c:/Projects/tstest/node_modules/siriwave.ts' does not exist.
File 'c:/Projects/tstest/node_modules/siriwave.tsx' does not exist.
File 'c:/Projects/tstest/node_modules/siriwave.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' does not have a 'types' field.
'package.json' does not have a 'main' field.
File 'c:/Projects/tstest/node_modules/siriwave/index.ts' does not exist.
File 'c:/Projects/tstest/node_modules/siriwave/index.tsx' does not exist.
File 'c:/Projects/tstest/node_modules/siriwave/index.d.ts' does not exist.
Directory 'c:/Projects/tstest/node_modules/@types' does not exist, skipping all lookups in it.
Directory 'c:/Projects/node_modules' does not exist, skipping all lookups in it.
Directory 'c:/node_modules' does not exist, skipping all lookups in it.
Loading module 'siriwave' from 'node_modules' folder, target file type 'JavaScript'.
Found 'package.json' at 'c:/Projects/tstest/node_modules/siriwave/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'c:/Projects/tstest/node_modules/siriwave.js' does not exist.
File 'c:/Projects/tstest/node_modules/siriwave.jsx' does not exist.
'package.json' does not have a 'main' field.
File 'c:/Projects/tstest/node_modules/siriwave/index.js' does not exist.
File 'c:/Projects/tstest/node_modules/siriwave/index.jsx' does not exist.
Directory 'c:/Projects/node_modules' does not exist, skipping all lookups in it.
Directory 'c:/node_modules' does not exist, skipping all lookups in it.
======== Module name 'siriwave' was not resolved. ========
As a workaround I have added "main": "dist/siriwave.js"
to package.json
but I’m not sure that this is the way to go with rollup.js compilation. Meaning I do not know if rollup.js js generates package.json for you or not. Any suggestions on how to make the library usable in Typescript in the sane way?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Import statement does not work in typescript - Stack Overflow
I read about import and export declarations in javascript. Then I'm trying to import a class in a file using 'import' keyword. But...
Read more >Common TypeScript module problems and how to solve them
Solution 2: Locate the module and resolve imports ; 'view/file2' with the first location in the array ( ; "*" ), and combine...
Read more >Imports not working in TypeScript project. · Issue #199 - GitHub
A workaround I found for this is declaring my own modules for the exports[] in package.json. open-props.d.ts. declare module "open-props/src/sizes"; ...
Read more >Documentation - Modules - TypeScript
Often modules extend other modules, and partially expose some of their features. A re-export does not import it locally, or introduce a local...
Read more >How to import a module in Typescript ? - GeeksforGeeks
Approach: Before importing any module we need to export it from another file. We can create a module by using the export keyword...
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 FreeTop 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
Top GitHub Comments
Sadly I know what happened to them… there is a bug in the
rollup-plugin-typescript
library. I have to generate d.ts files separately. I’m gonna fix it and publish probably today!This issue should’ve been closed, @kopiro it’s working - many, many thanks!