node-fs-extra: Cannot find module 'fs-extra/esm' or its corresponding type declarations.ts(2307)
Both 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
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (7 by maintainers)
@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)
FWIW I only found two packages among a long list of dependencies that we’re using that export as
./esm
(flatted and ts-node), and both also definemain
andmodule
in theirpackage.json
.PS: The polite way would have been to add a review to my PR and ask me to revert the changes to the
exports
field. Just saying.