Search code examples
node.jstypescriptfirebasefirebase-cli

Firebase login throws Error: spawn cmd ENOENT in NodeJS


I am trying to set up my Firebase TypeScript application on another system. When I execute firebase login, it throws the following exception:

[debug] [2020-07-10T12:35:28.031Z] ----------------------------------------------------------------------
[debug] [2020-07-10T12:35:28.034Z] Command:       C:\Program Files\nodejs\node.exe C:\Users\gp\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js login
[debug] [2020-07-10T12:35:28.034Z] CLI Version:   8.5.0
[debug] [2020-07-10T12:35:28.034Z] Platform:      win32
[debug] [2020-07-10T12:35:28.035Z] Node Version:  v12.18.2
[debug] [2020-07-10T12:35:28.036Z] Time:          Fri Jul 10 2020 18:05:28 GMT+0530 (India Standard Time)
[debug] [2020-07-10T12:35:28.036Z] ----------------------------------------------------------------------
[debug] [2020-07-10T12:35:28.037Z] 
[info] i  Firebase optionally collects CLI usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you.
 
[info] i  To change your data collection preference at any time, run `firebase logout` and log in again. 
[info] 
[info] Visit this URL on this device to log in:
[info] https://accounts.google.com/o/oauth2/auth?client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&scope=email%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloudplatformprojects.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffirebase%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&response_type=code&state=3839&redirect_uri=http%3A%2F%2Flocalhost%3A
[info] 
    [info] Waiting for authentication...
    [debug] [2020-07-10T12:57:25.170Z] Error: spawn cmd ENOENT
        at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
        at onErrorNT (internal/child_process.js:469:16)
        at processTicksAndRejections (internal/process/task_queues.js:84:21)
    [error] 
    [error] Error: An unexpected error has occurred.

On the new system, I am using the following software:

  • node v12.18.2
  • npm v6.14.5

On the old system, I was using the following software:

  • node v10.16.3
  • npm v6.12.0

I have also tried the following:

  • executing npm install -g firebase-tools@latest
  • executing all steps in a separate cmd running as admin.

Everything was working perfectly in my old workspace.


Solution

  • Fixed the issue by adding 'C:\Windows\System32' in my environment variable.