Powershell: npm having issues on powershell

Created on 9 Dec 2016  路  7Comments  路  Source: PowerShell/PowerShell

Tried all the available tricks like updating npm/nodejs version & other patches suggested on stackoverflow

Steps to reproduce

  1. On windows 10, install nodejs LTS version
  2. Update ComSpec environment variable from "C:\Windows\System32\cmd.exe" to "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" (I want make powershell as my default terminal )
  3. In powershell try "npm-v" or any npm install

Expected behavior

Should allow to use npm

Actual behavior

Getting below error

**C:Users\Ravishankar> npm -v
C:\Program : The term 'C:\Program' 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

  • C:\Program Files\nodejsnpm.cmd -v
  • ~~

    • CategoryInfo : ObjectNotFound: (C:\Program:String) [], CommandNotFoundException

    • FullyQualifiedErrorId : CommandNotFoundException**

Environment data


Operating system : Windows 10 Home
Nodejs version : 6.9.2 LTS as well tried with current version 7.2.1

C:Users\Ravishankar> $PSVersionTable

Name Value
---- -----
PSVersion : 5.1.14393.479
PSEdition : Desktop
PSCompatibleVersions : {1.0, 2.0, 3.0, 4.0...}
BuildVersion : 10.0.14393.479
CLRVersion : 4.0.30319.42000
WSManStackVersion : 3.0
PSRemotingProtocolVersion : 2.3
SerializationVersion : 1.1.0.1

Issue-Discussion Resolution-Answered

Most helpful comment

I am, too, expiriencing the problem.
WIN10, VS Code/ newest.
Can't install anything with NPM
npm : The term 'npm' 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
+ npm install
+ ~~~ + CategoryInfo : ObjectNotFound: (npm:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

All 7 comments

Not repro'ing for me:

Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\Users\slee> npm

Usage: npm <command>

where <command> is one of:
    access, adduser, bin, bugs, c, cache, completion, config,
    ddp, dedupe, deprecate, dist-tag, docs, edit, explore, get,
    help, help-search, i, init, install, install-test, it, link,
    list, ln, login, logout, ls, outdated, owner, pack, ping,
    prefix, prune, publish, rb, rebuild, repo, restart, root,
    run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, tag, team, test, tst, un, uninstall,
    unpublish, unstar, up, update, v, version, view, whoami

npm <cmd> -h     quick help on <cmd>
npm -l           display full usage info
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    C:\Users\slee\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

[email protected] C:\Program Files\nodejs\node_modules\npm
PS C:\Users\slee> npm -v
3.10.9

No repro for me either. I tried with Windows PowerShell and Alpha.13. Same result:

PS F:\Notes\> npm -v
3.10.8
PS F:\Notes\> where.exe npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd

Need better repro steps to be able to investigate this

@SteveL-MSFT : apologize for incomplete steps, Updated steps in original issue

I have updated my ComSpec environment variable from "C:\Windows\System32\cmd.exe" to "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"

however with "cmd" as a default terminal, It works without any issues.

I don't think it's recommended to change %comspec% to point to PowerShell.exe as existing apps will break if they use something like:

%comspec% /k foo.bat

From what I read, latest flight of Win10 has made powershell the default, but %comspec% still points to cmd.exe for compatibility reasons.

I am, too, expiriencing the problem.
WIN10, VS Code/ newest.
Can't install anything with NPM
npm : The term 'npm' 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
+ npm install
+ ~~~ + CategoryInfo : ObjectNotFound: (npm:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

First of all guys!! Remember this is not a Window PowerShell forum section. This is only for PowerShell Core issues.

If you got issues with NPM please go to their respective forums for support.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings