接收TS2304:找不到名称'文件'| TS2304:运行“npm run tsc”命令时找不到名称“ReadableStream”

问题描述 投票:-2回答:1

我有一个使用“watson-developer-cloud”模块的nodejs应用程序。使用“npm install --save watson-developer-cloud”包含此模块。

我在运行“npm run tsc”时看到了下面的问题。

node_modules/ibm-cloud-sdk-core/lib/content-type.d.ts(4,35): error TS2304: Cannot find name 'File'.
node_modules/ibm-cloud-sdk-core/lib/content-type.d.ts(4,42): error TS2304: Cannot find name 'ReadableStream'.

我在Mac上运行它。节点版本10.15.3。我发现很少有文章要求设置节点bin目录和重新加载终端的路径。我这样做了 - 虽然又遇到了同样的问题。

node_modules/ibm-cloud-sdk-core/lib/content-type.d.ts(4,35): error TS2304: Cannot find name 'File'.
node_modules/ibm-cloud-sdk-core/lib/content-type.d.ts(4,42): error TS2304: Cannot find name 'ReadableStream'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] tsc: `tsc`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] tsc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-03-25T14_29_06_333Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `npm run tsc && npm run tslint`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-03-25T14_29_06_351Z-debug.log
ERROR: Service 'my-program' failed to build: The command '/bin/sh -c npm run build' returned a non-zero code: 2```
node.js npm tsc npm-start
1个回答
0
投票

FileReadableStream类型在dom TypeScript库中定义。

尝试将其添加到您的tsconfig.json

{
  ...
  "compilerOptions": {
    "lib": [
      ...
      "dom"
    ]
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.