You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Module '"stream"' can only be default-imported using the 'esModuleInterop' flag #444
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?
Fixed in v14. The type declarations now import from ssh2 and stream with named imports only, so they no longer need esModuleInterop or allowSyntheticDefaultImports. I checked a strict project without either flag, using nodenext and node10, on TypeScript 5.9, 6 and 7.
Activity
steelbrain commentedon Nov 16, 2026
Fixed in v14. The type declarations now import from
ssh2andstreamwith named imports only, so they no longer needesModuleInteroporallowSyntheticDefaultImports. I checked a strict project without either flag, usingnodenextandnode10, on TypeScript 5.9, 6 and 7.Fix isConnected, Buffer keys, ~ in cwd and declaration imports