vscode: Unable to Debug Typescript: The terminal process "C:\WINDOWS\System32\wsl.exe -e npm run build" failed to launch

I receive the following error when trying to debug my typescript project

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

VSCode Version: Version: 1.51.0 (system setup) Commit: fcac248b077b55bae4ba5bab613fd6e9156c2f0c Date: 2020-11-05T18:18:23.642Z Electron: 9.3.3 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Windows_NT x64 10.0.19041

OS Version: Windows 10

Steps to Reproduce:

  1. Create a Typescript (Node) project with the following configuration
  2. Click the run button to start debugging

.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"
  ]
}

All the npm related commands in the package.json such as npm build, npm start etc. work fine from the wsl bash prompt

Does this issue occur when all extensions are disabled?: Yes

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (9 by maintainers)

Most upvoted comments

@alexr00 Thank you. Using the Remote WSL extension worked! Typing code . from WSL bash as mentioned in the article did not work. However clicking the green icon on the bottom left and opening the folder that way did work. I also upgraded to vscode v1.51.1 Hope this helps others.

P.S. Ok found the reason for why typing code . did not work. Apparently I had installed a version of code inside the WSL ubuntu. Did a sudo apt remove code to make bash use my vscode installation in Windows. Now everything works like a charm