-2

I'm trying to create Angular project using nvm. Executed below commands.

D:\Project1>nvm list

Output was: 14.16.1

Then, executed the below command.

F:\Ashok\Angular\Angular>nvm use 14.16.1

Output was: Now using node v14.16.1 (64-bit)

Below command has showed the correct node version which is fine.

F:\Ashok\Angular\Angular>node -v

Output was: v14.16.1

But, I'm getting error when trying to execute the below command.

F:\Ashok\Angular\Angular>ng -v

'ng' is not recognized as an internal or external command, operable program or batch file.

I've tried to install Angular-cli by using the below command. Looks like it's also worked well.

F:\Ashok\Angular\Angular>npm install @angular/cli

npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it! npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported

@angular/cli@11.2.9 postinstall F:\Ashok\Angular\Angular\node_modules@angular\cli node ./bin/postinstall/script.js

npm WARN Angular No description npm WARN Angular No repository field. npm WARN Angular No license field.

  • @angular/cli@11.2.9 added 7 packages from 4 contributors, removed 11 packages, updated 487 packages and audited 494 packages in 55.303s

26 packages are looking for funding run npm fund for details

found 0 vulnerabilities

I've tried to create Angular project by using the following command. But, I'm getting error. Can anyone please suggest me what is going wrong?

F:\Ashok\Angular\Angular>ng new my-first-project

'ng' is not recognized as an internal or external command, operable program or batch file.

Ashok kumar
  • 1,593
  • 4
  • 33
  • 68
  • If you want to use the ng command, either use npx or install it _globally_. – jonrsharpe Apr 16 '21 at 12:07
  • Hi @jonrsharpe, could you please elaborate on your suggestion! How can I use npx while considering nvm? How can I install ng globally? Sorry, but I'm pretty new to Angular, and I'm under pressure. – Ashok kumar Apr 16 '21 at 12:22
  • https://docs.npmjs.com/downloading-and-installing-packages-globally/, https://www.npmjs.com/package/@angular/cli, https://stackoverflow.com/q/54184357/3001761, ... – jonrsharpe Apr 16 '21 at 12:23
  • Does this answer your question? [Angular is not creating new project](https://stackoverflow.com/questions/66626009/angular-is-not-creating-new-project) – jonrsharpe Apr 16 '21 at 12:29
  • Hi @jonrsharpe, oh.. nice. But, these suggestions are not working for me now. I've done like below. F:\Ashok\Angular\Angular>npm install -g ng + ng@0.0.0 updated 1 package in 1.216s F:\Ashok\Angular\Angular>npm run ng new my-first-project npm ERR! missing script: ng npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Ashok\AppData\Roaming\npm-cache\_logs\2021-04-16T12_37_54_751Z-debug.log Please clarify me one more thing - if I use npx, does it invalid the use of nvm? – Ashok kumar Apr 16 '21 at 12:43
  • `npm run ng new` doesn't make sense, `npm run ng ...` would work if you had an `"ng"` entry in your package.json scripts, but before you run `ng new` you don't have a package for that package file to be in. And no, `npx` and `nvm` work together fine - `nvm` just controls which version of Node (and NPM, `npx`) is active. – jonrsharpe Apr 16 '21 at 13:07

1 Answers1

0

Nvm is a node version manager.

Npm is a node package manager.

So to create an Angular project you need to install Angular globally with npm

npm install -g @angular/cli

Have a look at Angular documentation for more details: https://angular.io/guide/setup-local

jpiazzal
  • 81
  • 6