I am trying to learn Angular and my knowledge in terminal is beginner. After I installed Angular and then type ng new my-project
. I get the response ng: command not found
. I've seen other posts that had this problem and I've uninstalled and reinstalled npm and ng.
The last step I took was npm install -g @angular/cli@latest then ng new my-project.
Then I get ng: command not found
.
Removing NODE and using NVM instead fixed a lot of issues.
LINK
You must know the full path of your angular installation. For example: C:\Users\\AppData\Roaming\npm\node_modules@angular\cli\bin\ng . Type in cmd, powershell or bash
*Windows only*
The clue is to arrange the entries in the path variable right.
As the NPM wiki tells us:
So your path variable will look something like:
…;C:\<path-to-node-installation>;%appdata%\npm;…
Now you have to possibilities:
Swap the two entries so it will look like
…;%appdata%\npm;C:\<path-to-node-installation>;…
This will load the npm version installed with npm (and not with node) and with it the installed Agnular CLI version.If you (for whatever reason) like to use the npm version bundled with node, add the direct path to your global Angualr CLI version. After this your path variable should look like this:
…;C:\Users\<username>\AppData\Roaming\npm\node_modules\@angular\cli;C:\<path-to-node-installation>;%appdata%\npm;…
or…;%appdata%\npm\node_modules\@angular\cli;C:\<path-to-node-installation>;%appdata%\npm;…
for the short form.This worked for me since a while now.
mocOS: ng command does not link in /usr/local/bin. I fixed the problem by adding it.
I had that same problem and just solved it.
make sure you have node installed.
after running
when installation is finished, try re-opening your git bash or whatever you're using or open it in a new folder. boom. it worked for me
If you have already installed
@angular/cli
Then you only need to link it to npm using
npm link @angular/cli
Otherwise first install angular by
npm install @angular/cli
and then link.