ng: command not found while creating new project using angular-cli

后端 未结 30 2688
忘掉有多难
忘掉有多难 2020-11-28 23:42

Installed angular-cli globally using (npm install -g angular-cli) but when I\'m trying to create project using ng new my-project it is throwing err

相关标签:
30条回答
  • 2020-11-29 00:06

    the easiest solution is (If you have already installed angular) :

    1 remove the ng alias if existing

    unalias ng
    

    2 add the correct alias

    alias ng="/Users/<user_name>/.npm-global/bin/ng"
    

    3 run ng serve for example and it will work.

    0 讨论(0)
  • 2020-11-29 00:09

    I've solved the same issue with adding an alias like:

    alias ng="path-to-your-global-node-modules/angular-cli/bin/ng"
    
    0 讨论(0)
  • 2020-11-29 00:09

    Firstly install '@angular/cli' by using npm as global module

    sudo npm install -g @angular/cli
    

    After that try to ping the cli by using 'ng' command from the terminal window.If any problem like

    Command 'ng' not found

    Then you need to manually setup the

    ng

    command availability.You set this step by running the following command.

    ln -s path-to-your-ng-command /bin
    

    eg:

    sudo ln -s /opt/node/lib/node_modules/@angular/cli/bin/ng /bin/

    0 讨论(0)
  • 2020-11-29 00:10

    In my case install angular cli

    npm install -g @angular/cli@latest
    

    update Nodejs to latest, then all should work fine.

    ...and if you still have that problem, it maybe because you run the command in shell and not in cmd (you need to run command in cmd), check this out and maybe it helps...

    0 讨论(0)
  • 2020-11-29 00:10

    This worked for me:

    1. Go to C:\Users{{users}}\AppData\Roaming and delete the npm folder
    2. Uninstall node and install it again
    3. Run the command to install angular cli

      npm install -g @angular/cli
      
    0 讨论(0)
  • 2020-11-29 00:12

    running

    export PATH=$PATH:/c/Users/myusername/AppData/Roaming/npm 
    

    helped.

    Make sure your actual username is in the myusername section

    0 讨论(0)
提交回复
热议问题