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

Module '"stream"' can only be default-imported using the 'esModuleInterop' flag #444

Open
sasa-cj-jovanovic opened this issue Sep 18, 2022 · 0 comments

Comments

@sasa-cj-jovanovic
Copy link

When compiling with typescript 4.8.3 (at this time latest version), I am getting this error:

node_modules/node-ssh/lib/typings/index.d.ts:2:8 - error TS1259: Module '"stream"' can only be default-imported using the 'esModuleInterop' flag

2 import stream from 'stream';
~~~~~~

node_modules/@types/node/stream.d.ts:333:5
333 export = internal;
~~~~~~~~~~~~~~~~~~
This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

When setting esModuleInterop to true, typescript renders other used libraries properties with getters only e.g.:

prompt.message = '';
^

TypeError: Cannot set property message of # which has only a getter
at Object. (/home/cj/auto-config/auto-config-init.js:161:16)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47

Workaround: Editing file node_modules/node-ssh/lib/typings/index.d.ts so the line at the begining:
import stream from 'stream';to be:
import * as stream from 'stream';
solves issue for me without esModuleInterop flag set.

Can you please add this change in the next version?

Thank you in advance CJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant