Skip to content

Instantly share code, notes, and snippets.

@FreeMasen
Last active November 9, 2017 16:45
Show Gist options
  • Save FreeMasen/a0dd3547954b676361eed77cbe2c044e to your computer and use it in GitHub Desktop.
Save FreeMasen/a0dd3547954b676361eed77cbe2c044e to your computer and use it in GitHub Desktop.
PowerShell Profile for autmatically adding ./node_modules/.bin to your path

notes

This is primarily useful for working with Visual Studio Code's integrated terminal because the $PWD property is set before PowerShell opens meaning that the test will be accurate. When using the external powershell window use the following command.

powershell -noexit -command cd "path/to/project"

To set your system to allow you to execute powershell scripts you need to run the following.

Set-ExecutionPolicy RemoteSigned -scope currentuser

see this article for more information

Powershell profile scripts are located in the following path.

C:\Users\[username]\Documents\WindowsPowershell\Microsoft.PowerShell_profile.ps1

if a file doesn't exist there create one. If you are using vs code a quick way to do this is to run the following.

code $profile

this will open the new file in vscode.

if (test-path "node_modules\.bin") {
$env:path = "$env:path$pwd\node_modules\.bin;"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment