(windows 11) alias for pnpm doesn’t work in VS code
Hi! I’m a newbie, I was switching from npm to pnpm and I followed the pnpm website guide, I have a problem. I use windows 11 btw. The integrated terminal in VS code doesn’t recognize the alias I set up for pnpm but it works if I open a terminal window outside of VS code. I’ve tried stack overflow solutions and didn’t work, I do have the path configured.
Hope someone can relate, thank you all.
Solution:Jump to solution
I figured it out. I'll share what I did in case you need it sometime or anyone else runs into this annoying set up
I ended up doing this:
"terminal.integrated.profiles.windows": {...
Stack Overflow
How to set aliases in Git Bash for Windows?
How to alias commands in Git Bash for Windows downloaded from git-scm?
I mean Bash commands, not Git.
I’m on Windows 7.
Edit:
Writing aliases in .bashrc file (as suggested by @gturri) not adding i...
6 Replies
I've run into a few issues like this.
- I would first look to ensure the standalone terminal and VSCode terminal are the same (git bash, powershell, something else).
- And make sure they're loading the same profile.
- And ensure they're loading the same startup script where your alias is defined. Could even have it
echo
something and check it appears in both when they start up.Ohh didn’t know by default the vs code terminal was running a different profile, yes, that might be it, I’ll check that thank you!
Update: still can't make it work. I've tried many different settings.json configurations but none seem to work.
I've tried following this guide https://code.visualstudio.com/docs/terminal/profiles#:~:text=To%20add%20Windows%20PowerShell%20as,set%20it%20as%20your%20default.
:c
IT RUNS BUT IT DOESN'T SET THE ALIAS.
>>>setting.json in VScode
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"args": [
"-NoExit",
"-Command",
"& 'C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1'"
]
},
}
That's supposed to run the script where i define the alias, It does, and I know it because This is the script and the echo runs eberytime i open a new terminal in vs code
>>>>profile.ps1
Set-Alias -Name pn -Value pnpm
echo "Hello from profile.ps1 | alias should be set up"
have you tried git bash?
It seems like you're going through alot more struggles than I had to deal with so I'm wondering if maybe powershell is a factor here
Yes, I wanted to set powershell as it is the default but I’ll rather set up bash instead. Thank you!
Solution
I figured it out. I'll share what I did in case you need it sometime or anyone else runs into this annoying set up
I ended up doing this:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"args": ["-NoExit", "-Command", "& Set-Alias -Name pn -Value pnpm"]
},
"Git Bash": {
"source": "Git Bash",
"args": ["--login"]
}
},
For the powershell terminal I had to pass the alias directly into the command that will execute every time i open a new terminal.. That was the only way I made it work.
For the GitBash, I could just tell VSCode to run the user profile everytime with "--login" (references "C:\Users\USERNAME.bashrc" It's where my alias is defined). For more info you can check this reference https://stackoverflow.com/questions/37104273/how-to-set-aliases-in-git-bash-for-windows
Stack Overflow
How to set aliases in Git Bash for Windows?
How to alias commands in Git Bash for Windows downloaded from git-scm?
I mean Bash commands, not Git.
I’m on Windows 7.
Edit:
Writing aliases in .bashrc file (as suggested by @gturri) not adding i...
Awesome glad you got it! Can you right-click > apps > mark solution on your answer 💯