簡體   English   中英

TypeScript:子進程未能處理請求:錯誤:調試失敗

[英]TypeScript : Child process failed to process the request: Error: Debug Failure

在執行nwb serve-react-demo時,我在 typescript 中遇到錯誤

子進程未能處理請求:錯誤:調試失敗。 虛假表達。 在 resolveNamesWithLocalCache (D:\Projects\react-techpulse-components\node_modules\typescript\lib\typescript.js:121409:26) 在 Object.resolveModuleNames (D:\Projects\react-techpulse-components\node_modules\typescript\lib\ typescript.js:121453:20) 在 Object.resolveModuleNames (D:\Projects\react-techpulse-components\node_modules\typescript\lib\typescript.js:123372:134) 在 actualResolveModuleNamesWorker (D:\Projects\react-techpulse- components\node_modules\typescript\lib\typescript.js:116593:153) 在 resolveModuleNamesWorker (D:\Projects\react-techpulse-components\node_modules\typescript\lib\typescript.js:116896:26) 在 resolveModuleNamesReusingOldState (D:\ Projects\react-techpulse-components\node_modules\typescript\lib\typescript.js:116994:24) 在 processImportedModules (D:\Projects\react-techpulse-components\node_modules\typescript\lib\typescript.js:118504:35)在 findSourceFileWorker (D:\Projects\react-techpulse-components\node_modules\t ypescript\lib\typescript.js:118284:17) 在 findSourceFile (D:\Projects\react-techpulse-components\node_modules\typescript\lib\typescript.js:118133:26) 在 processImportedModules (D:\Projects\react- techpulse-components\node_modules\typescript\lib\typescript.js:118539:25) 在 findSourceFileWorker (D:\Projects\react-techpulse-components\node_modules\typescript\lib\typescript.js:118284:17) 在 findSourceFile (D :\Projects\react-techpulse-components\node_modules\typescript\lib\typescript.js:118133:26) 在 processImportedModules (D:\Projects\react-techpulse-components\node_modules\typescript\lib\typescript.js:118539: 25) 在 findSourceFileWorker (D:\Projects\react-techpulse-components\node_modules\typescript\lib\typescript.js:118284:17) 在 findSourceFile (D:\Projects\react-techpulse-components\node_modules\typescript\lib\ typescript.js:118133:26) 在 processImportedModules (D:\Projects\react-techpulse-components\node_modules\typescript\lib\typescript.js:118539:25)

我使用的是 typescript 的 4.7.2 版本。
下面是我的 tsconfig 文件

{
  "compilerOptions": {
    "rootDir": "src",
    "declarationDir": "dist",
    "module": "esnext",
    "outDir": "dist",
    "target": "es5",
    "lib": ["es5", "es6", "es7", "es2017", "dom"],
    "sourceMap": true,
    "allowJs": true,
    "jsx": "react",
    "moduleResolution": "node",
    "rootDirs": ["src"],
    "forceConsistentCasingInFileNames": true,
    "removeComments": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true,
    "declaration": true,
    "allowSyntheticDefaultImports": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "noEmitHelpers": true,
    "importHelpers": true,
    "resolveJsonModule": true,
  },
  "files": [
    "src/index.ts",
  ],
  "include": [
    "src/**/*"
  ],
  "exclude": [
    "tests/**",
  ]
}

下面是我的 webpack 配置文件

var config = {
  type: 'react-component',
  npm: {
    esModules: true,
    umd: false
  },
  webpack: {
    config(config) {
      config.entry = {
        demo: ['./demo/src/index.js'],
      }
      config.resolve.extensions = ['.ts', '.tsx', '.js', '.jsx']
      config.module.rules.push({
        'test': /\.tsx?$/,
        'loader': 'awesome-typescript-loader',
      },{
        test: /\.scss$/,
        use: [
          "style-loader", // creates style nodes from JS strings
          "css-loader", // translates CSS into CommonJS
          {
            // compiles Sass to CSS, using Node Sass by default
            "loader": "sass-loader",
            "options": {
              "includePaths": ['src/styles', 'node_modules']
            }
          }
        ]
    })

      return config
    },
  },
}

使用"ts-loader"而不是"awesome-typescript-loader"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM