ethers.js: Build fails with latest Angular
Ethers Version
6.1.0
Search Terms
angular
Describe the Problem
Typescript shows this error when compiling:
Error: node_modules/ethers/types/providers/provider-ipcsocket.d.ts:1:23 - error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
1 /// <reference types="node" resolution-mode="require"/>
moduleResolution node16 or nodenext are not working with official angular setup & node is currently a default for new angular project. & due to this error build command is failing.
& as a workaround I have added "skipLibCheck": true
in tsconfig.
Code Snippet
No response
Contract ABI
No response
Errors
No response
Environment
node.js (v12 or newer)
Environment (Other)
Angular CLI
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 33 (13 by maintainers)
FYI, there is now an Angular environment CI test, thanks to your work. So, the CI will fail if there are any future issues building an Angular app.
See: https://github.com/ethers-io/ethers.js/blob/main/.github/workflows/test-env.yml#L56
Thanks! š
That version is still 3 months old, but it is likely fine. But if you look through the entire lock file, there are some places that specify a 5 year old (!!) version of babel. Iām not sure which dependency it pulls
asyncToGenerator
from, and that is the dependency to keep an eye on.Tomorrow I will make a few small changes locally to verify that is the problem and will also create a smaller proof-of-concept to demonstrate if it is the problem.
I donāt know Angular, so Iām just reading through their code as best I can.
Oh, the
node16
just gets rid of the warning re:reference types="blah"
and the"type": "module"
gets rid of the commonjs warning. Those are just warnings, so Iām not worried about them.Those are separate from the
this._getOptions
problem.When I looked at the
package-lock
they use all sorts of old versions of babel across their dependencies. It might just be a matter of updating whichever dependency is responsible for theasyncToGenerator
compiler. Iām not exactly sure where that is yet.I donāt really understand how this isnāt a larger problem for them; surely ethers canāt be the only library that uses arrow functions inside a method? :p
because this module use lib ānetā which is belong node lib
Sure, here are the steps:
npm install -g @angular/cli
ng new ethers-test-app
yarn/npm start
to see if app is workingyarn add ethers
ornpm i ethers
& import ethers lib in app.component.tsyarn/npm start
again to see compile error due to ethers import& ethers is not in package lock because I installed it using yarn, forgot to add package-lock in .gitignore.