首页 > 解决方案 > webpack 无法解析 d.ts 文件

问题描述

伙计们!

我尝试导入 d.ts 文件,但遇到以下错误: Field 'browser' doesn't contain a valid alias configuration

我猜,webpack 加载器有点麻烦,所以 webpack 无法处理 d.ts 文件。

webpack 模块

"webpack": "^5.27.2",
"webpack-cli": "^4.5.0",
"webpack-dev-server": "^3.11.2",
"webpack-merge": "^5.7.3"

错误:

ERROR in ./node_modules/extypes/typings/index.d.ts 3:0-27
Module not found: Error: Can't resolve './telegram' in 'D:\devprojects\node\changex\crm\node_modules\extypes\typings'
resolve './telegram' in 'D:\devprojects\node\changex\crm\node_modules\extypes\typings'
  using description file: D:\devprojects\node\changex\crm\node_modules\extypes\package.json (relative path: 
./typings)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: D:\devprojects\node\changex\crm\node_modules\extypes\package.json (relative path: ./typings/telegram)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        D:\devprojects\node\changex\crm\node_modules\extypes\typings\telegram doesn't exist
      .tsx
        Field 'browser' doesn't contain a valid alias configuration
        D:\devprojects\node\changex\crm\node_modules\extypes\typings\telegram.tsx doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        D:\devprojects\node\changex\crm\node_modules\extypes\typings\telegram.ts doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        D:\devprojects\node\changex\crm\node_modules\extypes\typings\telegram.js doesn't exist
      as directory
        D:\devprojects\node\changex\crm\node_modules\extypes\typings\telegram doesn't exist

有没有人遇到过这个问题?

标签: javascriptreactjstypescriptwebpack

解决方案


推荐阅读