Back to all posts

Fix Node binaries in VS Code Terminal šŸ¢

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 pathTerminal 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. šŸ˜Š