Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 无法调试VSCode上的Typescript_Node.js_Typescript_Visual Studio Code_Tsc_Vscode Tasks - Fatal编程技术网

Node.js 无法调试VSCode上的Typescript

Node.js 无法调试VSCode上的Typescript,node.js,typescript,visual-studio-code,tsc,vscode-tasks,Node.js,Typescript,Visual Studio Code,Tsc,Vscode Tasks,我试图在Windows 10上使用WSL作为默认shell从vscode调试一个typscript项目,但在单击“运行”按钮时出现以下错误 The terminal process "C:\WINDOWS\System32\wsl.exe -e npm run build" failed to launch (exit code: 1). 我做错了什么 .vscode/launch.json { "version": "0.2.0&qu

我试图在Windows 10上使用WSL作为默认shell从vscode调试一个typscript项目,但在单击“运行”按钮时出现以下错误

The terminal process "C:\WINDOWS\System32\wsl.exe -e npm run build" failed to launch (exit code: 1).
我做错了什么

.vscode/launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Debug",
            "program": "${workspaceFolder}\\src\\app.ts",
            "preLaunchTask": "npm: build",
            "sourceMaps": true,
            "smartStep": true,
            "internalConsoleOptions": "openOnSessionStart",
            "outFiles": [
                "${workspaceFolder}/dist/**/*.js"
            ]
        }
    ]
}
.vscode/settings.json

{
    "typescript.tsdk": "node_modules\\typescript\\lib"
}
package.json

{
    "name": "ts-sample",
    "version": "1.0.0",
    "description": "",
    "main": "dist/src/app.js",
    "scripts": {
      "start": "node dist/src/app.js",
      "prestart": "npm run build",
      "build": "tsc",
      "test": "echo \"Error: no test specified\" && exit 1"    
    },
    "repository": {
      "type": "git",
      "url": ""
    },
    "author": "",
    "license": "ISC",
    "bugs": {
      "url": ""
    },
    "homepage": "",
    "devDependencies": {
      "@types/express": "^4.17.1",
      "@typescript-eslint/eslint-plugin": "^4.4.0",
      "@typescript-eslint/parser": "^4.4.0",
      "eslint": "^7.11.0",
      "remove": "^0.1.5",
      "tslint": "^6.1.3",
      "typescript": "^4.0.5"
    },
    "dependencies": {
      "express": "^4.17.1",
      "inversify": "^5.0.1",
      "json-merge-patch": "^1.0.1",
      "reflect-metadata": "^0.1.13"    
    }
  }
tsconfig.json

{
  "compilerOptions": {      
    "esModuleInterop": true,            
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./src",
    "target": "es2017",
    "moduleResolution": "node",
    "module": "commonjs",
    "lib": ["es2017", "dom"],
    "types": ["reflect-metadata"],
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "resolveJsonModule": true
  },
  "lib": ["es2017"],
  "include": [
    "./src/**/*.ts",
    "./**/config*.json"
  ],
  "exclude": [ 
    "./dist/**/*",     
    "./node_modules"
  ]
}
package.json中所有与npm相关的命令,如
npm build
npm start
等,都可以在shell中正常工作