I have nodejs project that I want to run in debug mode in VSCode
Here is the Project structure
.vscode
- launch.json
services
- user
- server.ts
package.json
tsconfig.json
tslint.json
and here is the package.json scripts tag
"scripts": {
"clean": "del-cli ./dist/*",
"prestart": "yarn clean && tsc",
"start": "yarn serve",
"serve": "node dist/server.js",
"start-dev": "yarn prestart && concurrently \"tsc --watch \" \"nodemon dist/server.js\""
},
and the launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"cwd": "${workspaceFolder}",
"skipFiles": [
"<node_internals>/**"
],
"runtimeArgs": ["run-script","prestart"],
"runtimeExecutable": "npm",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
and this is showing
C:\Program Files\nodejs\npm.cmd run-script prestart
> myproj@1.0.0 prestart C:\PERSONAL\projects\myproj
> yarn clean && tsc && yarn copyfiles
c:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:255
c:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:71
Process exited with code 2
Update 1
it was raising issue because invalid path in tsconfig.json
{
"compilerOptions": {
"baseUrl": "./",
"target": "es2015",
"module": "commonjs",
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"pretty": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "dist",
"typeRoots": [
"node_modules/@types"
]
},
"include": [
"./**/*"
]
}
I updated include from src/**/*
to ./**/*
.
Now it compiling the typescript files but still exist with code 2.