#node.js #typescript #visual-studio-code #tsc #vscode-tasks
#node.js #typescript #visual-studio-code #tsc #vscode-задачи
Вопрос:
Я пытаюсь отладить проект typscript из vscode в Windows 10, используя WSL в качестве оболочки по умолчанию, но при нажатии кнопки выполнить появляется следующая ошибка
The terminal process "C:WINDOWSSystem32wsl.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" amp;amp; 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"
]
}
Все команды, связанные с npm, в package.json npm build
, такие как и т.д. npm start
отлично работает из оболочки