How to Create a specific version of Angular Project using CLI?

后端 未结 5 375
南方客
南方客 2020-12-24 01:40

My npm version is 5.5.1 and angular cli version is 6.2.1. When I try to create a new project using the command ng new Project_name<

相关标签:
5条回答
  • 2020-12-24 01:50

    You can use npx command which is Node.js package runner, by running packages directly from the registry without effecting the globally installed package registry (-g).

    @next will automatically install the latest preview version from Angular repo (now days refers to version 9 rc), like so:

    npx @angular/cli@next new Angular9Project
    

    Otherwise, you can provide the specific version:

    npx @angular/cli@7 new Angular7Project
    

    NPX comes bundled with NPM version 5.2+

    0 讨论(0)
  • 2020-12-24 01:57

    this should work Use a package called npx npm i -g npx and when you need to create an angular project use this command the first time npx -p @angular/cli ng new hello-world-project after that you can use normal commands to work like ng g c abc

    0 讨论(0)
  • 2020-12-24 02:06

    Create a package.json file then define the angular version you want to install then run npm install it will create project in the required version irrespective of the global angular cli

    0 讨论(0)
  • 2020-12-24 02:10

    The Easy Way: example:npm install -g @angular/cli@6 here the -g flag tells npm to do this install globally. The 6 on the end tells npm that I want the latest available version 6.

    if I want to create a new application for Angular 5 I do this :

    > npm install -g @angular/cli@1
    > ng new my-ng5-app
    

    Remember, Angular CLI was version 1.7 for Angular 5.

    if I want to create a new application for Angular 6 I do this :

    > npm install -g @angular/cli@6
    > ng new my-ng6-app
    

    if I want to create a new application for Angular 7 I do this :

    > npm install -g @angular/cli@7
    > ng new my-ng7-app
    

    I hope it would be helpful for you thanks....!

    read full blog click here

    0 讨论(0)
  • 2020-12-24 02:14

    Using CLI you can not create specific angular version.

    But you can install specific version of angular CLI into particular folder.

    For Example :

    First create new folder inside any drive. I'm going to create demo folder in D drive. Ex: d:\projects\demo.

    Then find this folder inside Command Prompt(cmd) or just type cmd into your created folder addressbar in windows and hit enter.

    Now type angular specific version command : npm install @angular/cli@1.7.x for angular 5. and use similar command for other version.

    After complete the installation, just create new angular project into your specific folder that you recently install angular. Ex: d:\projects\demo\.

    Now create angular project using the command ng new Project_name and it will create your specific angular version Project.

    In my example it will create angular 5 project.

    0 讨论(0)
提交回复
热议问题