Skip to content
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 'node:stream' or its corresponding type declarations #550

Closed
dpopp07 opened this issue Jul 26, 2022 · 5 comments
Closed
Assignees
Labels

Comments

@dpopp07
Copy link

dpopp07 commented Jul 26, 2022

I'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:42
  • node_modules/file-type/index.d.ts:1:42
  • node_modules/peek-readable/lib/StreamReader.d.ts:2:26
  • node_modules/strtok3/lib/core.d.ts:3:26
  • node_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:
Screen Shot 2022-07-26 at 3 26 41 PM

@Borewit
Copy link
Collaborator

Borewit commented Jul 27, 2022

From version file-type version 16 to 17, it changed from a CommonJS to ES-Module. To isolate the issue, you may want to try the latest 16.x first. Can you create a simple repo reproducing the issue @dpopp07?

1 similar comment
@Borewit
Copy link
Collaborator

Borewit commented Jul 27, 2022

From version file-type version 16 to 17, it changed from a CommonJS to ES-Module. To isolate the issue, you may want to try the latest 16.x first. Can you create a simple repo reproducing the issue @dpopp07?

@dpopp07
Copy link
Author

dpopp07 commented Jul 27, 2022

@Borewit thanks for the reply. Everything is working fine with 16.5.4, I ran into these issues when trying to use v17. I should be able to create a simple repo to reproduce, good idea. I'll try to do that soon

@dpopp07
Copy link
Author

dpopp07 commented Jul 28, 2022

Okay @Borewit I created a simple project to reproduce.

While I was putting this together, I learned that installing @types/node actually 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".

@Borewit
Copy link
Collaborator

Borewit commented Jul 29, 2022

Adding @types/node to Node.js TypeScript project is a common thing, as that kind of enables the types for the Node.js API. @types/node is 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/node typings via the dependent modules,

@Borewit Borewit self-assigned this Jul 29, 2022
@Borewit Borewit closed this as completed Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants