我正在尝试使用WSL作为默认Shell在Windows 10上的vscode上调试一个打字稿项目,但是单击运行按钮时出现以下错误
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上正常运行