Skip to content

Instantly share code, notes, and snippets.

@igorskyflyer
Last active September 22, 2023 19:28
Show Gist options
  • Save igorskyflyer/58ba22eb3ee8967a28ddb5f31a3ce83b to your computer and use it in GitHub Desktop.
Save igorskyflyer/58ba22eb3ee8967a28ddb5f31a3ce83b to your computer and use it in GitHub Desktop.
πŸ’£ Quickly fix and power up your Windows Terminal in VS Code with Node binaries! ⚑

When working with the Terminal in VS Code on Windows one the most frequent difficulty that all developers face is that the Terminal doesn't pick up local Node binaries, installed via npm install.


For example when working in an npm project and after successfully installing aria, if one tries to run it from the Terminal will see the following error:

Terminal error in VS Code caused by missing path Terminal error
Visual Studio Code theme: Kai


πŸ€” But why does this occur?

On Windows, system-wide PATH works correctly in the Terminal but the Terminal doesn't pick up local environment paths, thus, it cannot find any of the binaries that you want to execute.

To fix it we will need to add a setting inside the current user profile in VS Code and everything will work as expected. πŸ’‘


Navigate to your user profile's Settings by clicking on the cog icon βš™οΈ at the bottom of your Activity Bar. When the Settings tab has opened, click on the smaller cog icon βš™οΈ at the top right of the tab. That should get you to the current user profile's Settings file in JSON.

This is where the magic happens! πŸͺ„

Add the following code to your Settings JSON file:

"terminal.integrated.env.windows": {
	"PATH": "${workspaceFolder}\\node_modules\\.bin;${workspaceFolder}\\bin;${env:PATH}"
}

This will effectively allow you to run your current project's Node/npm binaries and the package's own exported binaries!


❗Note: you'll need to kill your current Terminal session and start a new one, to refresh the environment variables. If that doesn't work, restart VS Code itself.


That's it folks, let me know if it helped you fix a common pitfall. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment