2

For some reasons, I want to use Angular v5 if I run the below command,it builds an app in angular 6 which I don't want.

ng new hello //this creates angular app in the latest version

I ran the command in the below order

npm init //generated package.json

The above command generated package.json file, I swapped the content of package.json file.

https://jsoneditoronline.org/?id=5acc3c072e164c4a8235152516e44f54

npm install //installed all the node modules

now when I run command to generate the angular component (or any angular enitity) it throws the below error.

This command can only be run inside of a CLI project.

How do I make this app as angular CLI with Angular v5??

Kgn-web
  • 7,047
  • 24
  • 95
  • 161

2 Answers2

3

You can degrade version of cli globally npm install -g @angular/cli@1.7.4. With this cli will generate angular project on version 5.

Or

If you don't want to change your global angular/cli version you can create a new Angular project using npx @angular/cli@1.7.4 new hello.

Efe
  • 5,180
  • 2
  • 21
  • 33
  • this will affect the globally angualr cli version right?? – Kgn-web Jun 19 '18 at 13:27
  • Yes. If you just want to generate Angular app with version 5 you can use `npx @angular/cli@1.7.4 new hello`, then you don't have to change your global angular cli. – Efe Jun 19 '18 at 13:29
0

Don't degrade version as in Angular 4+ we don't use new to create new component Instead use generate command to make new component

ng generate component your_Comp_Name

T. Shashwat
  • 1,135
  • 10
  • 23