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:
š¤ 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. š