Search code examples
powershellcordovanpmcommand-prompt

Cordova is not recognised on command prompt. Variables have been updated


C:\Users\Admin>cordova
C:\Users\Admin\AppData\Roaming\npm\node_modules\cordova\node_modules\execa\index.js:347
                throw err;
                ^

Error: Command failed: powershell (Get-CimInstance -ClassName Win32_OperatingSystem).caption
'powershell' is not recognized as an internal or external command,
operable program or batch file.


    at makeError (C:\Users\Admin\AppData\Roaming\npm\node_modules\cordova\node_modules\execa\index.js:174:9)
    at Function.module.exports.sync (C:\Users\Admin\AppData\Roaming\npm\node_modules\cordova\node_modules\execa\index.js:338:15)
    at windowsRelease (C:\Users\Admin\AppData\Roaming\npm\node_modules\cordova\node_modules\windows-release\index.js:39:19)
    at osName (C:\Users\Admin\AppData\Roaming\npm\node_modules\cordova\node_modules\os-name\index.js:39:18)
    at new Insight (C:\Users\Admin\AppData\Roaming\npm\node_modules\cordova\node_modules\insight\lib\index.js:37:13)
    at Object.<anonymous> (C:\Users\Admin\AppData\Roaming\npm\node_modules\cordova\src\telemetry.js:26:15)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14) {
  code: 1,
  stdout: '',
  stderr: "'powershell' is not recognized as an internal or external command,\r\n" +
    'operable program or batch file.\r\n',
  failed: true,
  signal: null,
  cmd: 'powershell (Get-CimInstance -ClassName Win32_OperatingSystem).caption',
  timedOut: false
}

Solution

  • I was just having similar issues, there was a duplicate environment variable.

    System variables > Path > C:\Users\me\AppData\Local\Android\Sdk\platform-tools

    and

    System variables > Path > C:\Android

    Deleting the latter solved the issue. I entered the first path manually, the latter was input during an Android Studio installation.