Cannot find module 'node:stream' or its corresponding type declarations
See original GitHub issueI’ve just updated the file-type dependency in a TS package I maintain from v7 to v17. I made the necessary code updates but I cannot build my code with TS - I get several errors, all coming from file-type or associated packages from within node_modules. Every error is the same: Cannot find module 'node:stream' or its corresponding type declarations. and it occurs in 5 places:
node_modules/file-type/core.d.ts:1:42node_modules/file-type/index.d.ts:1:42node_modules/peek-readable/lib/StreamReader.d.ts:2:26node_modules/strtok3/lib/core.d.ts:3:26node_modules/strtok3/lib/ReadStreamTokenizer.d.ts:3:26
Any idea why I might seeing this? I’m not ruling out that it could be an issue in my environment but I’m not seeing any issue in my code, just in the dependencies.
I’ve tried with Node versions 14.17.5, 16.16.0, and 18.6.0.
I’ve also tried with TypeScript versions 4.7.4 (latest) and 3.8.3 (what we normally use for compatibility).
I would appreciate any insight here!
Screenshot of all the errors:

Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Related StackOverflow Question
Adding
@types/nodeto Node.js TypeScript project is a common thing, as that kind of enables the types for the Node.js API.@types/nodeis defined in peek-readable as a development dependency as well. I don’t think there is a good way I can automatically let you inherit@types/nodetypings via the dependent modules,Okay @Borewit I created a simple project to reproduce.
While I was putting this together, I learned that installing
@types/nodeactually resolves the issue. So there’s a fairly easy workaround. I just want to see if this is supposed to be a necessary sibling dependency in order to use this package with TypeScript. It doesn’t work “out of the box”.