-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find module 'ethers/providers' or its corresponding type declarations. #3703
Comments
If I change to moduelResolution to node16, error changes
|
I think you would want |
you can use this example to debug if needed |
"cp -Rn node_modules/ethers/types/* node_modules/ethers/lib.commonjs" this works for me in conjunction with use |
I might try this format: // package.json
{
"name": "my-package",
"type": "module",
"exports": {
".": {
// Entry-point for `import "my-package"` in ESM
"import": {
// Where TypeScript will look.
"types": "./types/esm/index.d.ts",
// Where Node.js will look.
"default": "./esm/index.js"
},
// Entry-point for `require("my-package") in CJS
"require": {
// Where TypeScript will look.
"types": "./types/commonjs/index.d.cts",
// Where Node.js will look.
"default": "./commonjs/index.cjs"
},
}
},
// Fall-back for older versions of TypeScript
"types": "./types/index.d.ts",
// CJS fall-back for older versions of Node.js
"main": "./commonjs/index.cjs"
} |
Quick question; what version of TypeScript are you using? |
4.9.4 |
I fixed this by just adding declaration generation to the Thanks for your research! :) |
I get the same error using the same config file in v6.0.7.
typescript@4.9.5 My original tsconfig.json works fine in v5 but not in v6. I'll get the error above: {
"compilerOptions": {
"target": "es2020",
"module": "esnext",
"strict": true,
"esModuleInterop": true,
"moduleResolution": "node16",
"skipLibCheck": true,
"noUnusedLocals": true,
"noImplicitAny": true,
"allowJs": true,
"resolveJsonModule": true,
"experimentalDecorators": true
},
"exclude": ["dist"]
}
I think we should drop |
The |
Alternatively, output the dist js file with ext |
The problem with The east solution is just to re-include the |
I've re-added the types, since re-ordering the exports didn't seem to resolve the issue. |
Error: Cannot find module 'ethers/lib/utils' Still getting the above error in next js app structure and in an nx repo Do anyone by any chance have a solution ? |
The |
node_modules/ethers/types/index |
Ethers Beta Version
6.0.0-beta-exports.15
Describe the Problem
Hi,
I tried to use
import { EventFilter, LogParams, Network } from 'ethers/providers'
since they are not available inethers
module. But typescript failed to compile because can't find type declarationMy environment is node 16, yarn 1.22 type script 4.9.4, my tsconfig.json looks like this:
Code Snippet
No response
Errors
No response
Environment
node.js
Environment (Other)
No response
The text was updated successfully, but these errors were encountered: