Skip to content

"Could not find the ng executable." Error #6187

Closed

Description

@jwowillo

[REQUIRED] Environment info

firebase-tools:

Firebase CLI Version: 12.4.6

Platform:

Ubuntu

[REQUIRED] Test case

firebase deploy --only hosting

.firebaserc:

{
  "projects": {
    "default": "county-collector"
  },
  "targets": {},
  "etags": {}
}

firebase.json:

{
  "hosting": {
    "source": ".",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "frameworksBackend": {
      "region": "us-central1"
    }
  }
}

Outputs:
Error: Could not find the ng executable.

[REQUIRED] Steps to reproduce

  1. npm install @angular/cli: Note that ng executable path from which ng is /usr/local/bin/ng
  2. Install Firebase CLI
  3. firebase deploy --only hosting

[REQUIRED] Expected behavior

Correctly deploys angular app or describes documentation to change ng path.

[REQUIRED] Actual behavior

Fails to find ng executable.

[2023-07-26T15:09:51.656Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2023-07-26T15:09:51.657Z] > authorizing via signed-in user (<EMAIL>)
[2023-07-26T15:09:51.657Z] [iam] checking project county-collector for permissions ["firebase.projects.get","firebasehosting.sites.update"]
[2023-07-26T15:09:51.659Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/<PROJECT-NAME>:testIamPermissions [none]
[2023-07-26T15:09:51.662Z] >>> [apiv2][(partial)header] POST https://cloudresourcemanager.googleapis.com/v1/projects/<PROJECT-NAME>:testIamPermissions x-goog-quota-user=projects/county-collector
[2023-07-26T15:09:51.663Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/<PROJECT-NAME>:testIamPermissions {"permissions":["firebase.projects.get","firebasehosting.sites.update"]}
[2023-07-26T15:09:51.798Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/<PROJECT-NAME>:testIamPermissions 200
[2023-07-26T15:09:51.798Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/<PROJECT-NAME>:testIamPermissions {"permissions":["firebase.projects.get","firebasehosting.sites.update"]}
[2023-07-26T15:09:51.799Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/<PROJECT-NAME> [none]
[2023-07-26T15:09:52.061Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/<PROJECT-NAME> 200
[2023-07-26T15:09:52.061Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/<PROJECT-NAME> {"projectId":"<PROJECT-NAME>","projectNumber":"<PROJECT-NUMBER>","displayName":"<PROJECT-NAME>","name":"projects/<PROJECT-NAME>","resources":{"hostingSite":"<PROJECT-NAME>","storageBucket":"<PROJECT-NAME>.appspot.com","locationId":"us-central"},"state":"ACTIVE","etag":"1_ed644d71-71cc-47e7-a03a-f03620977b42"}

   Thank you for trying our early preview of Angular support on Firebase Hosting.
   During the preview, support is best-effort and breaking changes can be expected. Proceed with caution.

   Documentation: https://firebase.google.com/docs/hosting/frameworks/angular
   File a bug: https://github.com/firebase/firebase-tools/issues/new?template=bug_report.md
   Submit a feature request: https://github.com/firebase/firebase-tools/issues/new?template=feature_request.md

   We'd love to learn from you. Express your interest in helping us shape the future of Firebase Hosting: https://goo.gle/41enW5X


Error: Could not find the ng executable.

Activity

  1. aalej commented on Jul 27, 2023

    @aalej
    Contributor

    Hi @jwowillo, thanks for reaching out. I’m unable to reproduce the error you mentioned. The steps I took were:

    1. Run ng new my-app
    2. Run cd my-app
    3. Run firebase init hosting --project <project_id>
    4. Run firebase deploy

    There’s a couple of things I’d like to ask to get a better overview of what might be causing this:

    1. Are you encountering a similar error message when running firebase emulators:start, or does it run without any issues?
    2. Does running npm i or npm install then re-deploying via firebase deploy produce a different behavior?
    3. In your node_modules directory, do you see a ./bin/ng file?
    4. Which version of Node.js you're using?
  2. added
    Needs: Author Feedback
    on Jul 27, 2023
  3. jwowillo commented on Jul 27, 2023

    @jwowillo
    Author
    1. Are you encountering a similar error message when running firebase emulators:start, or does it run without any issues?

    I encounter the exact same issue.

    1. Does running npm i or npm install then re-deploying via firebase deploy produce a different behavior?

    No, it doesn't produce a different behavior.

    1. In your node_modules directory, do you see a ./bin/ng file?

    The path in node_modules is: node_modules/@angular/cli/bin/ng.js. My angular CLI version is 16.1.4.

    1. Which version of Node.js you're using? v18.16.1
  4. added and removed
    Needs: Author Feedback
    on Jul 27, 2023
  5. CarlosFlores24 commented on Aug 4, 2023

    @CarlosFlores24

    Any updates on this? I have same issue as OP under similar conditions:

    ENVIRONMENT INFO
    -Firebase CLI V12.4.7
    -Angular CLI V16.1.6
    -npm: 9.8.0
    -node.js: 18.16.1
    -Platform: Windows10

    TEST CASE
    .firebaserc

    {
      "targets": {
        "robotics-club-management": {
          "hosting": {
            "robotics-club-management-app": [
              "robotics-club-management"
            ]
          }
        }
      },
      "projects": {
        "default": "robotics-club-management"
      }
    }
    

    firebase.json

    {
      "hosting": {
        "source": ".",
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ],
        "frameworksBackend": {
          "region": "us-central1"
        }
      },
      "public": "dist/robotics-club-management-app"
    }
    

    STEPS TO REPRODUCE
    (Same as above)

    EXPECTED BEHAVIOUR
    Correctly deploys angular app or describes documentation to change ng path.

    ACTUAL BEHAVIOUR

    PS [project_path]> firebase emulators:start
    i  emulators: Starting emulators: auth, firestore, hosting
    
       Thank you for trying our early preview of Angular support on Firebase Hosting.
       During the preview, support is best-effort and breaking changes can be expected. Proceed with caution.
    
       Documentation: https://firebase.google.com/docs/hosting/frameworks/angular
       File a bug: https://github.com/firebase/firebase-tools/issues/new?template=bug_report.md
       Submit a feature request: https://github.com/firebase/firebase-tools/issues/new?template=feature_request.md
    
       We'd love to learn from you. Express your interest in helping us shape the future of Firebase Hosting: https://goo.gle/41enW5X
    
    i  emulators: Shutting down emulators.
    i  hub: Stopping emulator hub
    
    Error: Error finding ng executable: failed to spawn 'npm'
    

    Additionally, firebase emulators:start doesn't work form me either. Also, the ng.js file does exist inside node_modules/bin/. I also ran npm install and the problem is still unsolved.

  6. DiegoVenancioVieira commented on Sep 24, 2023

    @DiegoVenancioVieira

    Two situations that it happened with me:
    1 - Detected an existing Angular codebase in the current directory, should we use this?
    2 - Do you want to use a web framework? (experimental) ?

    both situations if YES error occurs. Then NO and works fine.

  7. AgustinFrich commented on Oct 12, 2023

    @AgustinFrich

    Two situations that it happened with me: 1 - Detected an existing Angular codebase in the current directory, should we use this? 2 - Do you want to use a web framework? (experimental) ?

    both situations if YES error occurs. Then NO and works fine.

    This worked for me, the error is gone

  8. self-assigned this
    on Nov 29, 2023
  9. leoortizz commented on Nov 29, 2023

    @leoortizz
    Member

    Looks like this is the same issue that was fixed in #6372, which was released in v12.6.0. Can you all check the latest firebase-tools version?

  10. leoortizz commented on Dec 4, 2023

    @leoortizz
    Member

    Fixed by #6372

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions