[@types/node] Compiler error: Cannot find module 'undici-types' #67406
Replies: 12 comments 2 replies
-
Thanks for the discussion about "node", some useful links for everyone: Pinging the DT module owners: @microsoft, @jkomyno, @alvis, @r3nya, @btoueg, @smac89, @Touffy, @DeividasBakanas, @eyqs, @Hannes-Magnusson-CK, @hoo29, @kjin, @ajafff, @islishude, @mwiktorczyk, @mohsen1, @n-e, @galkin, @parambirs, @eps1lon, @ThomasdenH, @WilcoBakker, @wwwy3y3, @samuela, @kuehlein, @bhongy, @chyzwar, @trivikr, @yoursunny, @qwelias, @ExE-Boss, @peterblazejewicz, @addaleax, @victorperin, @ZYSzys, @nodejs, @LinusU, @wafuwafu13, @mcollina, @Semigradsky. |
Beta Was this translation helpful? Give feedback.
-
Try to reinstall dependencies. |
Beta Was this translation helpful? Give feedback.
-
The issue seems to only occur when building with yarn, building with pnpm works as expected |
Beta Was this translation helpful? Give feedback.
-
Same issue started appearing in a release from 3 weeks ago |
Beta Was this translation helpful? Give feedback.
-
This definitely seems like a bug with the types, running tsc will yield
In a project that does not need or use nodenext for modules. (or undici or any other dependencies) |
Beta Was this translation helpful? Give feedback.
-
If you are coming across this in your own projects, as a workaround, you can {
"compilerOptions": {
"paths": {
// This is solely to stop a bug with @types/node as of 12/15/2023
"undici-types": [
"./node_modules/undici-types/index.d.ts"
],
}
}
} And it will work for now. |
Beta Was this translation helpful? Give feedback.
-
In my case, the culprit was |
Beta Was this translation helpful? Give feedback.
-
This is only an issue if you are not using
This has no effect for me. |
Beta Was this translation helpful? Give feedback.
-
I just ran into the same issue. Because of this bug, merely installing
... even though the code being compiled didn't use any Node types. The suggestion to set For now I've downgraded |
Beta Was this translation helpful? Give feedback.
-
Some external libraries may require the use of Commonjs. In such cases, you may encounter problems, and you will need to find alternative solutions .Adding "Moduleresolution": "Node" to your TSCONFIG.JSON file helps the Typescript compiler to determine how to allow modules. This can be useful if you switch your project to use ES6 modules, especially when problems arise with resolving modules and conflicts with various modules systems. |
Beta Was this translation helpful? Give feedback.
-
I had the same issue and what resolved it was to create a separate config file for the type script files that were causing it (in my case client.ts):
|
Beta Was this translation helpful? Give feedback.
-
For me, this is causing failure on a basic TypeScript project with no dependencies other than |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am unable to compile Firefox extension using web-ext because of the following error in
@types/node
moduleBeta Was this translation helpful? Give feedback.
All reactions