[英]Process exited with code 2 while debug in nodejs vscode
I have nodejs project that I want to run in debug mode in VSCode我有想要在 VSCode 中以调试模式运行的 nodejs 项目
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这是 package.json 脚本标签
"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和发射。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更新 1
it was raising issue because invalid path in tsconfig.json它引发了问题,因为 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 ./**/*
.我将包含从
src/**/*
更新为./**/*
。
Now it compiling the typescript files but still exist with code 2.现在它编译 typescript 文件,但代码 2 仍然存在。
I found我发现
An error code (also exit code) of 2 means "File not found"
In my case, project contains multiple sub projects.就我而言,项目包含多个子项目。 The dependency is mentioned in package.json but it was not installed somehow, so by running
package.json 中提到了依赖项,但它没有以某种方式安装,所以通过运行
npm install
command, worked for me.命令,为我工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.