Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng : The term 'ng' is not recognized as the name of a cmdlet, function Visual Studio Code Terminal

In VS Code when I am running command ng build, getting error

PS D:\Dashboard\Test1> ng build
ng : The term 'ng' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if   
a path was included, verify that the path is correct and try again.
At line:1 char:1
+ ng build
+ ~~
    + CategoryInfo          : ObjectNotFound: (ng:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I have added these environment variable in Path

%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;
C:\Users\Avind\AppData\Local\Programs\Microsoft VS Code\bin;
C:\Users\Avind\AppData\Roaming\npm;

How can I get rid of this issue?

Note: I have node.js at C:\Program Files\nodejs. From command prompt ng new project not working but working from node.js command.

Edit 1: After executing npm install -g @angular/cli@latest from VS Code terminal getting below msg and ng cmd not working

PS D:\Path\Test1> npm install -g @angular/cli@latest
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
C:\Users\Avind\AppData\Roaming\npm\ng -> C:\Users\Avind\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng

> @angular/[email protected] postinstall C:\Users\AR20095474\AppData\Roaming\npm\node_modules\@angular\cli
> node ./bin/postinstall/script.js

+ @angular/[email protected]
updated 1 package in 53.477s
like image 506
R15 Avatar asked Jun 23 '20 04:06

R15


2 Answers

You need to install the latest angular cli to make the ng command work, you can run it from the command termial or visual studio code terminal

npm install -g @angular/cli@latest

if still not working, uninstall and reinstall node.js from program and feature.

like image 175
Sajeetharan Avatar answered Oct 20 '22 19:10

Sajeetharan


As here Angular CLI, Make sure you installed Angular CLI
You can run this command from anywhere on your system

npm install -g @angular/cli
ng --version

Should print something like that

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 13.1.2
Node: 16.13.1
Package Manager: npm 8.1.2
OS: win32 x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1301.2 (cli-only)
@angular-devkit/core         13.1.2 (cli-only)
@angular-devkit/schematics   13.1.2 (cli-only)
@schematics/angular          13.1.2 (cli-only)
like image 39
CorrM Avatar answered Oct 20 '22 19:10

CorrM