Cannot find module 'fs-extra/esm' or its corresponding type declarations.ts(2307)
See original GitHub issueBoth importing from fs-extra and fs-extra/esm doesn’t work anymore in v11.0.0. I tried the following lines in my fs.ts file:
import { ensureDirSync, ensureFileSync, removeSync } from 'fs-extra'
import { ensureDirSync, ensureFileSync, removeSync } from 'fs-extra/esm'
The top line does work in v10.1.0. Am I doing something wrong?
- Operating System: Ubuntu 22.04.1 LTS
- Node.js version: v16.18.0
fs-extra
version: v11.0.0
Issue Analytics
- State:
- Created 10 months ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Cannot find module or its corresponding type declarations ...
About the declaration for your parser you could use the pegjs/typings/generated-parser.d.ts from your node modules as a starting point.
Read more >cannot find module 'yup' or its corresponding type declarations ...
The code editor is showing the error mentioned in the title (Cannot find module 'global.module.css' or its corresponding type declarations.ts(2307)) ...
Read more >error TS2307: Cannot find module 'type-fest/source/simplify' or ...
Updating to version 7.36.1 breaks our build with the following error npm install type-fest --save-dev appears to be a workaround, ...
Read more >fs-extra - npm
fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.
Read more >Custom Widget: Cannot find module or its correspon...
I have written a widget using JS API 4.16/TypeScript and I'm ... Widget: Cannot find module or its corresponding type declarations.ts(2307).
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
@RyanZim I just had a quick skim through https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html and found this:
Based on that, this should work:
In other words, removing
main
frompackage.json
may have removed TypeScript support.Update: Just double checked, and those changes resolve the issue with TypeScript.
(Background: https://github.com/mdn/yari/pull/7697)
Yeah, this is shorthand notation: https://nodejs.org/api/packages.html#exports-sugar I’m curious if changing it to an object with only
default
would also fix TS support (not sure I want to do that as the actual fix, as it’s non-intuitive). Based on this, it seems this would be a potential bug that TS should fix?