TypeScript - module.exports 报错 TS2591:找不到名称 'module'

6

我有一个名为config.ts的文件,其中包含以下代码:

let config = {
  foo: {
    bar: [{env: "test"}...],
    ...
    ...
  }
};

module.exports = config;

我想在整个应用程序中使用这个文件。

然而,这段代码会导致以下错误:

ERROR in src/app/configs/config.ts:357:1 - error TS2591: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.

357 module.exports = config;

我已经检查过,我的@types/node已经安装,并且tsconfig.json文件在compilerOptions下包含了"types": ["node"]

如何解决这个问题?

1个回答

3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接