为什么 Typescript 结果:找不到模块 './config/config.json' 或其相应的类型声明

问题描述

我的json配置文件路径是

myapp-[config/config.json,src,outdir,....,tsconfig.json]

我在 import configfrom from './config/config.json'; 上使用:index.ts

这是我的 tsconfig.json 文件

{
    "compilerOptions": {
        "module": "commonjs","allowJs": true,"esModuleInterop": true,"experimentalDecorators": true,"emitDecoratorMetadata": true,"target": "es6","noImplicitAny": false,"moduleResolution": "node","sourceMap": true,"resolveJsonModule": true,"outDir": "app","baseUrl": "./","paths": {
            "*": [
                "node_modules/*"
            ]
        }
    },"exclude": [
    "config"
  ],"include": [
        "src/**/*"
    ]
}

但是,当我编译时,我有一个结果:error TS2307: Cannot find module './config/config.json' or its corresponding type declarations.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)