steelbrain / steelbrain/node-ssh

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

Open
#444 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1k
Forks
94
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The reported declaration is node-ssh/lib/typings/index.d.ts; start by checking its stream import under TypeScript 4.8.3 without esModuleInterop. Verify that the package type-checks and existing runtime usage still works without requiring consumers to enable esModuleInterop.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
networking
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.