Typescript Winston 编译错误
Typescript Winston Compile Errors
我想使用 winston 在使用 TypeScript 的 NodeJS 应用程序中记录错误。但是每当我将 Winston 导入 Typescript 脚本时,我都会遇到同样的 11 个错误:
node_modules/winston-transport/index.d.ts:6:23 - error TS2688: Cannot find type definition file for 'node'.
6 /// <reference types="node" />
~~~~
node_modules/winston-transport/index.d.ts:8:25 - error TS2307: Cannot find module 'stream'.
8 import * as stream from 'stream';
~~~~~~~~
node_modules/winston/index.d.ts:4:23 - error TS2688: Cannot find type definition file for 'node'.
4 /// <reference types="node" />
~~~~
node_modules/winston/index.d.ts:6:31 - error TS2307: Cannot find module 'stream'.
6 import * as NodeJSStream from "stream";
~~~~~~~~
node_modules/winston/index.d.ts:121:28 - error TS2503: Cannot find namespace 'NodeJS'.
121 stream(options?: any): NodeJS.ReadableStream;
~~~~~~
node_modules/winston/index.d.ts:165:34 - error TS2503: Cannot find namespace 'NodeJS'.
165 let stream: (options?: any) => NodeJS.ReadableStream;
~~~~~~
node_modules/winston/lib/winston/config/index.d.ts:4:23 - error TS2688: Cannot find type definition file for 'node'.
4 /// <reference types="node" />
~~~~
node_modules/winston/lib/winston/transports/index.d.ts:4:23 - error TS2688: Cannot find type definition file for 'node'.
4 /// <reference types="node" />
~~~~
node_modules/winston/lib/winston/transports/index.d.ts:6:21 - error TS2307: Cannot find module 'http'.
6 import {Agent} from "http";
~~~~~~
node_modules/winston/lib/winston/transports/index.d.ts:31:14 - error TS2503: Cannot find namespace 'NodeJS'.
31 stream?: NodeJS.WritableStream;
~~~~~~
node_modules/winston/lib/winston/transports/index.d.ts:77:13 - error TS2503: Cannot find namespace 'NodeJS'.
77 stream: NodeJS.WritableStream;
~~~~~~
我只添加了常规的 winston 作为依赖,而不是 @types/winston(我已经用那个包试过了,但没有帮助)。
我使用 import * as winston from 'winston'
导入 winston
看来 winston 在 TypeScript 中也需要 @types/node。一旦我将它添加为依赖项 (npm i @types/node
),它就起作用了!
我想使用 winston 在使用 TypeScript 的 NodeJS 应用程序中记录错误。但是每当我将 Winston 导入 Typescript 脚本时,我都会遇到同样的 11 个错误:
node_modules/winston-transport/index.d.ts:6:23 - error TS2688: Cannot find type definition file for 'node'.
6 /// <reference types="node" />
~~~~
node_modules/winston-transport/index.d.ts:8:25 - error TS2307: Cannot find module 'stream'.
8 import * as stream from 'stream';
~~~~~~~~
node_modules/winston/index.d.ts:4:23 - error TS2688: Cannot find type definition file for 'node'.
4 /// <reference types="node" />
~~~~
node_modules/winston/index.d.ts:6:31 - error TS2307: Cannot find module 'stream'.
6 import * as NodeJSStream from "stream";
~~~~~~~~
node_modules/winston/index.d.ts:121:28 - error TS2503: Cannot find namespace 'NodeJS'.
121 stream(options?: any): NodeJS.ReadableStream;
~~~~~~
node_modules/winston/index.d.ts:165:34 - error TS2503: Cannot find namespace 'NodeJS'.
165 let stream: (options?: any) => NodeJS.ReadableStream;
~~~~~~
node_modules/winston/lib/winston/config/index.d.ts:4:23 - error TS2688: Cannot find type definition file for 'node'.
4 /// <reference types="node" />
~~~~
node_modules/winston/lib/winston/transports/index.d.ts:4:23 - error TS2688: Cannot find type definition file for 'node'.
4 /// <reference types="node" />
~~~~
node_modules/winston/lib/winston/transports/index.d.ts:6:21 - error TS2307: Cannot find module 'http'.
6 import {Agent} from "http";
~~~~~~
node_modules/winston/lib/winston/transports/index.d.ts:31:14 - error TS2503: Cannot find namespace 'NodeJS'.
31 stream?: NodeJS.WritableStream;
~~~~~~
node_modules/winston/lib/winston/transports/index.d.ts:77:13 - error TS2503: Cannot find namespace 'NodeJS'.
77 stream: NodeJS.WritableStream;
~~~~~~
我只添加了常规的 winston 作为依赖,而不是 @types/winston(我已经用那个包试过了,但没有帮助)。
我使用 import * as winston from 'winston'
看来 winston 在 TypeScript 中也需要 @types/node。一旦我将它添加为依赖项 (npm i @types/node
),它就起作用了!