Node.js TypeScript-module.exports抛出错误TS2591:找不到名称';模块';
我有一个名为Node.js TypeScript-module.exports抛出错误TS2591:找不到名称';模块';,node.js,typescript,Node.js,Typescript,我有一个名为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
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
文件包含“types”:[“node”]
在编译器选项下
如何解决此问题?来自:
尝试导出默认配置,而不是模块。导出=配置