Home > Article > Development Tools > Introduction to the method of remote debugging Node program with vscode
This article will introduce to you how to remotely debug Node programs with vscode. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Video tutorial recommendation: vscode basic tutorial、node js tutorial
First, open the SSH server function in the remote server. The ubuntu system is basically All come with it, if not, install it
apt-get install openssh-server
Download the VScode Insider version, and then install the Remote Development extension. After installing the Remote Development extension, other Remote-SSH will automatically Installation, if it does not install automatically, please install it manually according to the screenshot.
To configure username/password authentication, you need to edit the settings.json file of VSCode. The way to open it is as shown below. Click setting and click any one of 'Edit in settings.json'. '.
Then add "remote.SSH.showLoginTerminal": true in settings.json
Click " open a remote window", select 'connect to Host'
##Open config according to the order of the pictures file, and fill in the Host and login name of the remote host A new window will pop up. According to the prompts, enter the Linux password File->Open Folder (or File)to display the Linux folder (or file)
1. Open the Git installation directory and put Git\usr\bin into the environment variable.
2. Then open the process and edit the directory of the host config file C:\Users\ye\.ssh (the user name will be different on different computers), and execute ssh-keygen.
3. We need Copy the id_rsa.pub file to the ~/.ssh/ directory on the Linux server. If there is no such directory, please execute mkdir ~/.ssh to create it, and then remotely transfer id_rsa.pub to the directory.
4. Then switch to the directory and execute cat id_rsa.pub >> ; authorized_keys,
5. Modify
PubkeyAuthentication yes,
, are the two items normal? If there are comments, please cancel them. If they are not the same, please modify or add
7. Then return to the Windows command line and execute ssh (user name)@192.168.160.132
Please replace the ones in the brackets with yours Linux username, please be sure to log in according to this format, be sure to enter the username and IP, do not just enter the IP
此时打开文件的时候就不会再提示输入密码了
找到远程服务器中 node 的路径
which node
在 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", "program": "${workspaceFolder}/server/server.js", "runtimeExecutable": "/root/.nvm/versions/node/v8.6.0/bin/node" // 就增加这行 } ] }
更多编程相关知识,请访问:编程入门!!
The above is the detailed content of Introduction to the method of remote debugging Node program with vscode. For more information, please follow other related articles on the PHP Chinese website!