Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git bash can not run any ng command (Angular CLI)

I'm working on git bash cmd. When I try run ng command e.g. ng serve or ng gc new-component I see this output:

C:\Users\user\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found

In the middle of output I see problem with left and right slash. How can I fix it?

I suppose, it isn't problem with environment paths, because all ng commands are working in Windows cmd or PowerShell.

like image 260
Pawel Avatar asked Apr 13 '20 18:04

Pawel


People also ask

Why is NG command not working?

The error “ng command not found” occurs when your system's shell cannot find the path to the ng cli binary. There are three major causes of this error: The ng CLI is not installed. The ng CLI is located in a different directory.

How do you check if angular cli is installed?

Use the command ng --version (or ng -v ) to find the version of Angular CLI in the current folder. Run it outside of the Angular project, to find out the globally installed version of Angular. Use the npm list --depth 0 to find out the list of packages installed in the current folder.

What is Ng command?

The ng new command creates an Angular workspace folder and generates a new application skeleton. A workspace can contain multiple applications and libraries. The initial application created by the ng new command is at the top level of the workspace.

Where can I find Ng?

ng binary is located inside of bin/ (or in the folder specified at the next line).


1 Answers

Please see comments from @steveswork at: https://github.com/nodejs/node/issues/29287

You have to delete C:/Users/user/AppData/Roaming/npm and C:/Users/user/AppData/Roaming/npm-cache and reinstall global npm modules.

(This typically happens after an upgrade or downgrade of node)

Good Luck.

like image 61
Mamun Avatar answered Nov 09 '22 23:11

Mamun