I installed the Serverless Framework using the following NPM command
npm install -g serverless
When I try to run the serverless command sls
in Powershell, I get a strange result which mentions "cmdlet Select-string".
sls --version
Can someone help me with this issue?
It seems that PowerShell has a command/cmdlet called Select-String which has an alias of sls. The PowerShell alias sls seems to take precedence over the node.js serverless command of sls.
One way to remove the PowerShell sls alias is by running the following in PowerShell
Remove-Item alias:sls
This change only applies to the current PowerShell session.
To permanently the sls PowerShell alias, you can change Microsoft.PowerShell_profile.ps1 file.
From PowerShell open your profile page in Notepad with the following command:
notepad $profile
Add the following to the file and save.
remove-item alias:sls
The profile can be reloaded by running the following from Powershell
. $profile
In my file, you will see that I have removed the aliases of curl and sls.
Now I see what I expect when entering sls in PowerShell.
How do I permanently remove a default Powershell alias?
--- Update ----
A more simple option is to use the command "serverless" instead of "sls".
For future visitors - in current version (if serverless
is installed by npm/yarn
) ^1.61
there is a secondary shortcut option:
slss
and that shortcut works flawlessly in Powershell. Imo it's the simplest way to avoid problems with Select-String
alias collision and do not require any change in Powershell session or config.
PS C:\htdocs\serverless> slss -v
Framework Core: 1.61.1
Plugin: 3.2.7
SDK: 2.2.1
Components Core: 1.1.2
Components CLI: 1.4.0
If serverless
is installed by chocolatey
(as mentioned by @Nick Cox in comment) slss
approach will fail, and you can use approach suggested by him - sls.exe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With