Setup Visual Studio Code Node Debugging
Microsoft Visual Studio Code is a great editor for NodeJS development, and the built in debugger is awesome. Except that it fails to start if you are using the latest versions of NodeJS... if you want to use new features like async/await, you will like this tool!
Installing
Prerequisites
npm i -g setup_vs_code_debug
Getting Started
Run these commands in your terminal:
cd <YOUR_PROJECT_DIR>
setup_vs_code_debug
The above command will configure the the most version of NodeJS to work with VS Code's debugger. If you would like to target a different version of NodeJS:
setup_vs_code_debug X.X.X
To start debugging, open any of your project JS files in VS Code and hit
FN + F5
on a mac (try F5
or WIN + F5
on other systems).
You can always overwrite the version of Node to debug against by running the command again.
How To Debug NodeJS in Visual Studio Code
Under The Hood
.
├── .nvmrc
└── .vscode
└── launch.json
The version of NodeJS you are debugging with in VS Code will be persisted in .nvmrc
.
To run your app with that version, type this into your terminal:
cd <YOUR_PROJECT_DIR>
nvm use
node <YOUR_JS_FILE>
Your VS Code Debugger config will be saved in .vscode/launch.json
.
Uninstalling
You can safely remove setup_vs_code_debug
at any time, and your VS code configs will
still be saved.
npm uninstall -g setup_vs_code_debug
Found a bug? Want a new feature?
- please create an issue on the github page
Author
- Mike Situ - Github Repos
License
This project is licensed under the MIT License - see the LICENSE.md file for details