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

オープン
#444 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
node.js, typescript
領域
networking

調査の方向性

報告された宣言は node-ssh/lib/typings/index.d.ts です。まず、esModuleInterop なしの TypeScript 4.8.3 でその stream の import を確認してください。package が型チェックを通過し、既存のランタイム使用が、利用者に esModuleInterop の有効化を要求せずに引き続き機能することを検証してください。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
1k
フォーク
94
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

steelbrain/node-ssh のほかの issue

steelbrain/node-ssh の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。