2

Using Windows 10, I can't run certain commands from PowerShell but they all work correctly using cmd.

PowerShell:

node --version:

node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ node --version
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (node:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

node.exe --version: no output.

node.exe: opens a new black console (node.exe application itself).

Get-Host | Select-Object Version:

Version
-------
5.1.19041.906

Get-Command node: The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Get-Command node + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (node:String) [Get-Command], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand

Get-Command node.exe: CommandType Name Version Source ----------- ---- ------- ------ Application node.exe 14.16.1.0 C:\Program Files\nodejs\node.exe

$env:Path output has nodejs & git & other paths.

cmd:

everything works fine with any command.

I have git and nodejs in my PATH env variable.

What's wrong with PowerShell, what a strange behavior is this and how to fix it?

8
  • 1
    while in PoSh check $env:Path -split ';' | Sort-Object to see if the path in that session is what is needed. please remember that the path will also vary per account AND powershell host ... so make sure to test in the exact same setup that your current failure shows up in.
    – Lee_Dailey
    Commented May 24, 2021 at 15:52
  • @Lee_Dailey yes, everything is in path... The most surprising behavior is that having or not ".exe" matters somewhy! Commented May 24, 2021 at 16:24
  • 1
    @VitalySenko - Edit your question to include that information
    – Ramhound
    Commented May 24, 2021 at 16:43
  • @VitalySenko - that likely means you have something in your path that is executable in some way AND that matches node. you may want to search for the unwanted item [perhaps node.js?] and either remove it OR rearrange your path sequence.
    – Lee_Dailey
    Commented May 24, 2021 at 20:22
  • So when you run node.exe, a new window pops up? That’s not normal. How do you start Powershell? What about other programs like notepad or cmd?
    – Daniel B
    Commented May 25, 2021 at 8:19

0

You must log in to answer this question.