ng: command not found while creating new project using angular-cli
NickName:lego Ask DateTime:2016-05-14T22:22:02

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

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 error:

ng: command not found

Copyright Notice:Content Author:「lego」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/37227794/ng-command-not-found-while-creating-new-project-using-angular-cli

Answers
faye.babacar78 2020-01-15T16:11:00

If you have installed angular cli globally but ng isn't working, just do this:\n\necho -e \"export PATH=$(npm prefix -g)/bin:$PATH\" >> ~/.bashrc\n\nsource ~/.bashrc\n\nng --version\n",


Darío Gutiérrez 2016-10-12T03:36:02

Do you install the node js package? https://nodejs.org/en/\nRegards",


Callat 2019-09-24T04:22:16

I came here because I had the same issue on windows. The thing that baffled me most on this was I have had Node installed since Angular 4 dabbling here and there. And sure enough. That was my problem. I needed to upgrade node. \n\nJust installing the newest version worked fine for me without having to do any of the above steps post the new install",


m.zemlyanoi 2016-10-20T15:30:28

I've solved the same issue with adding an alias like:\n\nalias ng=\"path-to-your-global-node-modules/angular-cli/bin/ng\"\n",


user7486067 2017-04-08T01:57:32

if you find this error when you are installing angular-cli, \n-bash: ng: command not found try this it works,\n\nAfter removing Node from your system\n\ninstall NVM from here https://github.com/creationix/nvm\nInstall Node via NVM: nvm install stable\nrun npm install -g angular-cli\n",


abhinavroy23 2017-12-20T11:37:51

The issue is simple, npm doesn't know about ng\n\nJust run npm link @angular/cli and it should work seamlessly.",


gatsby 2019-09-09T08:58:12

Adding %AppData%\\npm to the Win path have worked for me.\n\nSource : https://github.com/angular/angular-cli/issues/1183 , the first comment.",


nPcomp 2018-12-06T21:46:23

According to npm, the angular-cli has been renamed to @angular/cli you can use the following syntax to install it.\n\nnpm install -g @angular/cli\n",


VanAlbert 2017-07-23T13:25:06

First, angular-cli is deprecated and has been replaced with @angular/cli. So if you uninstall your existing angular-cli with npm uninstall angular-cli, then reinstall the package with the new name @angular/cli you might get some conflicts. My story on Windows 7 is:\n\nI had installed angular-cli and reinstalled using npm install -g @angular/cli, but after doing some config changes to command-line tools, I started getting the ng command not found issue. I spent several hours trying to fix this but none of the above issues alone worked. I was able to fix it using these steps:\n\nInstall Rapid Environment Editor and remove any PATH entries for node, npm, angular-cli or @angular/cli. Node.js will be in your System path, npm and angular entries are in the User path.\n\nUninstall node.js and reinstall the current version (for me 6.11.1).\nRun Rapid Environment Editor again and make sure node.js and npm are in your System or User path.\nUninstall any existing ng versions with:\n\nnpm uninstall -g angular-cli\n\nnpm uninstall -g @angular/cli\n\nnpm cache clean\n\n\nDelete the C:\\Users\\%YOU%\\AppData\\Roaming\\npm\\node_modules\\@angular folder.\n\nReboot, then, finally, run:\n\nnpm install -g @angular/cli\n\n\nThen hold your breath and run:\n\nng -v\n\nIf you're lucky, you'll get some love. Hold your breath henceforward every time you run the ng command, because 'command not found' has magically reappeared for me several times after ng was running fine and I thought the problem was solved.",


Al Fahad 2021-08-25T11:13:51

I was facing same issue, I was using git bash terminal, I installed angular cli using this command\nnpm install -g @angular/cli\n\nbut when I try to create new app it was giving me error ng: command not found, I just restarted my pc and it worked, even closing and opening terminal again will also fix issue sometimes",


Clairton Luz 2021-04-05T12:55:43

If you are using asdf-vm you need run adsf reshim nodejs to recreate links with global modules.\nIn my case this resolve my problem, I hope resolve to you all too.",


fuma 2017-01-17T12:32:21

Make sure that the npm directory is in your \"Path\" variable.\n\nIf the module is installed properly, it may work if you start it out of your global node module directory, but your command line tool doesn't know where to find the ng command when you are not in this directory.\n\nFor Win system variable add something like:\n\n%USERPROFILE%\\AppData\\Roaming\\npm\n\n\nAnd if you use a unix-like terminal (emulator):\n\nPATH=$PATH:[path_to_your_user_profile]/path-to-npm\n",


mayank parihar 2018-02-13T10:15:23

First of all, check if your npm and node installed properly \nwith commands npm version and node -v.\n\nIf they are proper:\n\n\nFind the root global Directory of NPM npm root -g (it will\ngive you root of your global npm store) \nUninstall old angular cli with npm uninstall -g angular-cli\nand npm cache clean\nReinstall new Version of angular npm install -g @angular/cli@latest\nmake an Alias of Name ng:\n\n\nalias ng=\"C:/ProgramData/npm/node_modules/@angular/cli/bin/ng\"\n\nalias ng=\"<ath-to-your-global-node-modules>/<angular cli path till ng>\"\n(from answered Oct 20 '16 at 15:30 @m.zemlyanoi )\n\nthen to check you can type ng -v ",


Piotr Antończak 2021-05-23T18:44:19

Most likely the problem is that you are using PowerShell and not the command line. If you use Windows PowerShell run:\ncmd\n\nthen next try:\nng --version\n\nif it works run:\nng new my-project\n",


Achref Gassoumi 2018-01-24T05:45:54

the easiest solution is (If you have already installed angular) :\n\n1 remove the ng alias if existing\n\nunalias ng\n\n\n2 add the correct alias \n\nalias ng=\"/Users/<user_name>/.npm-global/bin/ng\"\n\n\n3 run ng serve for example and it will work.",


Roman Mahotskyi 2019-05-15T09:51:16

For Mac users:\n\n1) Install @angular/cli globally\n\n$ sudo npm install -g @angular/cli\n/usr/local/Cellar/node/10.0.0/bin/ng -> /usr/local/Cellar/node/10.0.0/lib/node_modules/@angular/cli/bin/ng\n\n\n2) Create alias for ng\n\nalias ng=\"/usr/local/Cellar/node/10.0.0/lib/node_modules/@angular/cli/bin/ng\"\n\n\nDone",


raja manikkam 2017-06-22T17:56:11

soluton for windows operating system only.......\nfirst step:\n\ninstall nodejs version: nodev 8.1.2\n\nsecond step:\nset up environment variable like: C:\\ProgramFiles\\nodejs\n\nThird step:\ninstall angular use this command: npm install -g @angular/cli\n\nafter installation whereever you have to create project like: ng new first-project......",


Divyanshu Rawat 2019-03-15T09:52:06

This is how I made it worked for me :).\n\n1 - npm link @angular/cli\n\nIt will return you the path of cli, which will look like this \n\n/usr/local/Cellar/node/11.3.0_1/lib/node_modules/@angular/cli\n\n\nFor this part, /11.3.0_1 please replace this with your respective node version that can be found by typing node --version\n\n2 - cd ~/\n\n3 - open .bash_profile\n\nIn the bash profile create an alias for cli like this,\n\nalias ng=\"/usr/local/Cellar/node/11.3.0_1/lib/node_modules/@angular/cli/bin/ng\"\n\n4 - source ~/.bash_profile\n\nThis is how your .bash_profile will look like once you add alias to it.\n\n\n\nNow typing ng in the terminal will display output shown in attached snapshot.\n\n\n\nI hope this answer will be helpful.",


Ali 2019-06-15T23:08:43

try this :\n\nalias ng=\"~/node_modules/@angular/cli/bin/ng\"",


Justin.Cooke 2018-05-06T20:26:10

For me (on MacOSX) I had to do:\n\nnvm install stable\nnpm install -g angular-cli\n\n\nThis installed ng into:\n\n/usr/local/lib/node_modules/@angular/cli/bin/ng\n\n\nBut npm did not put a link to ng into \n\n/usr/local/bin/\n\n\nWhich was why it was not part of the %PATH and therefore available from the command line except via an absolute address.\n\nSo I used the following the create a link to ng:\n\nsudo ln -sf /usr/local/lib/node_modules/\\@angular/cli/bin/ng /usr/local/bin/ng\n",


Francesco 2019-01-11T03:15:57

For Mac run\n\nnpm install -g @angular/cli@latest\n\nthen run\n\nalias ng=\"/usr/local/lib/node_modules/node/lib/node_modules/@angular/cli/bin/ng\"\n\n\nCheck if working\n\nng version\n",


Maihan Nijat 2017-07-09T22:34:48

Make sure angular-cli is installed before trying to create a project. Windows users can install angular-cli without giving permission to command but MAC users have to use sudo before executing the command as follow:\n\nsudo npm install -g angular-cli\n\n\nType a password when asked and press enter to proceed.",


PrJ 2018-07-28T13:01:57

This worked for me:\n\n\nGo to C:\\Users{{users}}\\AppData\\Roaming and delete the npm folder\nUninstall node and install it again\nRun the command to install angular cli\n\nnpm install -g @angular/cli\n\n",


Ali Jamal 2019-10-04T21:25:20

In my case install angular cli\n\nnpm install -g @angular/cli@latest\n\n\nupdate Nodejs to latest, then all should work fine.\n\n...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...",


Matt Kane 2016-11-14T20:38:41

Same problem here running Windows 10 x64 / NodeJS 6.9.1 / npm 3.10.9. After installation of Angular CLI via npm: \n\n\n 'ng' command cannot be found\n\n\nDo the following:\n\n\nUninstalled npm with npm uninstall -g npm \nUninstalled NodeJS via control panel / programs and features \nDownloaded and ran 'old' NodeJS installer release 6.5.0 from https://nodejs.org/download/release/v6.5.0/ (node-v6.5.0-x64.msi).\nAfter NodeJS 6.5.0 installation completed, open powershell and npm install -g angular-cli\nGrab quick coffee\nAfter installation completed, ng worked OK.\n\n\nHTH",


Fey Agape 2019-02-11T15:34:38

running\n\nexport PATH=$PATH:/c/Users/myusername/AppData/Roaming/npm \n\n\nhelped. \n\nMake sure your actual username is in the myusername section",


Gajender Singh 2018-07-11T06:02:24

Run below commands:\n\nnpm uninstall -g angular-cli\n\nnpm uninstall -g @angular/cli\n\nnpm cache clean\n\nnpm install -g @angular/cli@latest\n\n\nalias ng=\"C:/Users/itaas/.npm-global/ng\" ( Location of ng file in npm folder) \n\nAnd finally run :\n\nng -v \n\n\n",


abhinav 2021-03-31T07:30:03

For mackBook OS\nsudo npm uninstall -g @angular/cli\nsudo npm cache verify\nsudo npm install -g @angular/cli@latest\n\ntry with ng -v if not work then set alias and try\nalias ng="/usr/local/Cellar/node/10.0.0/lib/node_modules/@angular/cli/bin/ng"\n",


Glance 2019-05-03T13:42:15

Repairing NodeJS installation on windows resolved it for me. ",


More about “ng: command not found while creating new project using angular-cli” related questions

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

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 error: ng: command not found

Show Detail

Project name is invalid while creating the project with ng new command

I am installed the latest version of angular-cli on my local and trying to create a new project using the command ng new ETG.WEB.UI --style=scss. I am getting error message Project name ETG.WEB.UI...

Show Detail

ng command not found angular-cli when create new project in windows

i am successfully install node.js and angularjs2 using this command. node version is node version v6.9.1 npm install -g angular-cli and the installation path is that C:\Users\Arobil\AppData\R...

Show Detail

error while creating new project with Angular-cli

When I am trying to create new project by using the command, ng new project-name, I am getting error like below: fs.js:640 return binding.open(pathModule._makeLong(path), stringToFlags(flags)...

Show Detail

Error when creating new project with Angular-CLI 6.1.2

I tried creating a new Angular project using ng new angular-6-boilerplate but I can't do it anymore with angular-cli latest version. I'm using terminal for windows to create my project but I got this

Show Detail

Error when creating new project with Angular-CLI 6.1.2

I tried creating a new Angular project using ng new angular-6-boilerplate but I can't do it anymore with angular-cli latest version. I'm using terminal for windows to create my project but I got this

Show Detail

build command using ng-build not working with @angular-cli

ng-build is not working with @angular-cli although it works fine with @angular/cli Error - You have to be inside an angular-cli project in order to use the build command.

Show Detail

Error while running ng serve command in Angular 2 project

I have recently created a project using angular-cli and am unable to run it using ng serve while running ng serve command it throws this error Cannot read property 'AssetUrl' of undefined

Show Detail

You have to be inside an angular-cli project in order to use the build command after reinstall of angular-cli

I had the latest angular-cli installed globally and my project was building successfully. While reading a suggested solution for another issue, (https://github.com/angular/angular-cli/issues/917...

Show Detail

Cannot use new command inside angular-cli project

It's quite possible that an angular project was accidentally created inside my home folder in mac osx. So every time I try and create a new project using the angular-cli I receive "You cannot use t...

Show Detail