Skip to content

'ng' is not recognized as an internal or external command, operable program or batch file. #6501

Closed

Description

@awsaunier

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

  • node v7.10.0
  • npm v4.2.0
  • Windows 10 Version 1703 build 15063.332

Repro steps.

I installed and uninstalled the cli and node several times and even manually cleaned node caches after uninstalling and it refuses to recognize 'ng'. The installer never fails with no error message. when you call 'ng' it will recognize

The log given by the failure.

C:\Users\awsau>ng help
'ng' is not recognized as an internal or external command,
operable program or batch file.

Desired functionality.

Mention any other details that might be useful.

  • I had done a fresh install of windows using the included program "Fresh Start" that is included with windows before installing the cli.
  • I had previously had this problem a few months ago but fixed it by updating node and cleaning the cache manually.

Activity

  1. sumitarora commented on May 29, 2017

    @sumitarora
    Contributor

    @awsaunier Can you provide the stack trace of CLI install? Also, check the global node_modules if it's installed or not?

  2. awsaunier commented on May 29, 2017

    @awsaunier
    Author

    I included a txt file of the stack. I didn't want to include it in here due to its long length.
    Stack.txt
    I don't know how to check Install for the node_modules is installed or not but I did do a search on my c: and I did find a node_modules folder was in C:\Program Files\nodejs\node_modules.

  3. MrRhino commented on May 29, 2017

    @MrRhino

    I have the same issue.

    For Windows 10 users only

    You can not install ng from the command line with a non administrator account
    And there is no sudo. Only runas which runs as the administrator with the administrator profile.
    The UAC does not kick in and ask you to provide admin permissions as when you run an installer.
    So the ng binary will be located in the Administrator npm folder after installing using the runas feature.

    Take a look at the folder "C:\Users\Administrator\AppData\Roaming\npm" and see if you can spot ng.
    If you can then add "C:\Users\Administrator\AppData\Roaming\npm" to your path.

    There is something called sudo for windows ( https://sourceforge.net/projects/sudowin/ )
    It runs with elevated permissions, while preserving your profiling settings.
    I haven't tried it. Use at own risk.

  4. awsaunier commented on May 29, 2017

    @awsaunier
    Author

    ##edited##
    I looked at my Admin account and you were right, it was installed there but I tried to use the 'ng' command on the admin account and it still does not work and gives me the same error. Is there a way to redirect that to a standard user account? In the past I was able to do all my development on a standard user account. Also I don't quite understand what you mean by.

    If you can then add "C:\Users\Administrator\AppData\Roaming\npm" to your path.

  5. awsaunier commented on May 30, 2017

    @awsaunier
    Author

    I some further investigation and I upgraded my user account to admin and reinstalled angular cli and it now works. I was able to downgrade my account to a standard user and it still works. I don't know if this is still an windows issue related to what @MrRhino said and if this can be solved by an update to the cli. The thing that is puzzling me is that I was able to use the cli and everything fine a month ago and now having this issue. I am glad I can continue to code and I thank everyone that has help.

  6. MrRhino commented on May 30, 2017

    @MrRhino

    Is there a way to redirect that to a standard user account?

    No.

    If you can then add "C:\Users\Administrator\AppData\Roaming\npm" to your path.

    I mean if you have ng in the above mentioned path, then add it to your current user path.

    I some further investigation and I upgraded my user account to admin and reinstalled angular cli and it now works. I was able to downgrade my account to a standard user and it still works.

    That is also a solution. But it still requires that you have administrator permissions.

    The thing that is puzzling me is that I was able to use the cli and everything fine a month ago and now having this issue

    Maybe Microsoft tightened their User Account Control

    Personally i would add the administrator path "C:\Users\Administrator\AppData\Roaming\npm" to my current user path along with your current user path "C:\Users<currentUser>\AppData\Roaming\npm".
    That way all global modules will be available to you, even when you are required to install via. the administrator account.

  7. awsaunier commented on May 30, 2017

    @awsaunier
    Author

    Personally i would add the administrator path

    What do you mean by add and where should I add the path?

  8. MrRhino commented on May 30, 2017

    @MrRhino

    Hit the Windows button ( cmd on Mac ) and write "Environment"

    Select the option that says "Environment variables for your account" ( or similar in your own language )

    Select Path

    Select New and add "C:\Users\Administrator\AppData\Roaming\npm"

    Press Ok and finish

  9. filipesilva commented on Jun 1, 2017

    @filipesilva
    Contributor

    Thanks to @MrRhino for the advice and solution steps.

    I'd just like to add that it is possible to install (to the best of my knowledge) to install Angular CLI on non-admin accounts. The missing bit seems to have been that the npm path was not part of the environment path, and thus global npm binaries could not be found.

  10. naru6be commented on Jul 22, 2017

    @naru6be

    At last find the solution for ng command is not working issue ,Find the solution below http://itechiesol.blogspot.com/2017/07/angular-cli-ng-command-is-not-working.html

  11. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  12. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions