How to debug code vscode in nodejs

Recent contact with a front-end react, nodejs do the project forward layer package to deploy is no longer a purely static files on the server, but to start the project after the installation node and packaged on the server, because of the need required in the project debuge nodejs so record it

 

package.json the script as follows (dev attention to):

"scripts": {
    "build": "cross-env NODE_ENV=production TS_NODE_PROJECT=\"tsconfig.webpack.config.json\" webpack --config webpack.config.ts && tsc --build tsconfig.build.json",
    "build:uat": "cross-env NODE_ENV=uat TS_NODE_PROJECT=\"tsconfig.webpack.config.json\" webpack --config webpack.config.ts && tsc --build tsconfig.build.json && mv ./build/server.uat.js ./build/server.js",
    "test:lint": "tslint -c tslint.json '{src,packages}/**/*.{ts,tsx}'",
    "dev": "cross-env NODE_ENV=development SERVER_PORT=3000 CONSOLE_CONFIG=\"config/console.dev.json\" node -r ts-node/register/transpile-only ./server.dev.ts",
    "start": "ts-node ./server.ts"
  },

 

The following vscode tasks.json (task.json is arranged to perform the above script script dev)

{
 // documentation for tasks.json format, see 
    // https://go.microsoft.com/fwlink/?LinkId=733558 
    "Version": "2.0.0" ,
     "Tasks" : [ 
        {
             "of the type" : "NPM" ,
             "Script": "dev" , // together is RUN dev NPM
             "problemMatcher" : [] 
        } 
    ] 
}

 

The following vscode launch.json (launch.json configuration parameters to set the startup script, as follows, in .vscode / launch.json file, the red portion is provided operating conditions, the yellow part of the configuration script script)

{
   // use IntelliSense understanding of the relevant property. 
  // hover to see the existing property description. 
  // For more information, please visit: https://go.microsoft.com/fwlink/?linkid=830387 
  "Version": "0.2.0" ,
   "the Configurations" : [ 
    {
       "of the type": "the Node" , 
      "Request": "Launch" ,
       "name": "the Launch Program" ,
       "runtimeArgs": [ "-R & lt", "TS-Node / Register / transpile-only" ],
       "the env" : {
         "NODE_ENV": "Development" ,
         "SERVER_PORT": "3000" ,
         ""CONSOLE_CONFIG_PATH": "C:\\Users\\jim.hu\\Desktop\\project\\operaconnector-console"
      },
      "args": ["${workspaceFolder}\\server.dev.ts"]
    }
  ]
}

 

Guess you like

Origin www.cnblogs.com/jimaww/p/12486513.html