How to create angular 5 project in angular cli 6.0.1

前端 未结 2 627
無奈伤痛
無奈伤痛 2020-12-30 09:00

My angular cli version is 6.0.1 and node version is 8.11.1.

How to create or add a new project of angular

2条回答
  •  鱼传尺愫
    2020-12-30 09:17

    I stumbled upon this scenario too.
    Here is my solution to it.

    Unfortunately we are at the CLI's mercy, as the best way to create a new Angular project scaffolding.
    Considering ng new {app_name} does not support a version flag.
    Our aim would be to get the right CLI version installed.

    The following steps helped me workaround this:

    1. Create a new folder: mkdir ng-5-cli && cd ng-5-cli
    2. Initialise NPM npm init
    3. Install older Angular CLI: npm i @angular/cli@1.7.4 --save-dev
    4. For some reason now the ng compiler assumes this is a angular project directory and does not allow running ng new here.
    5. Step out of the current directory: cd ..
    6. Use the absolute path to Angular cli in the directory from step #1.

    For example /ng-5-cli/node_modules/.bin/ng new some-ng5-app

    This should create a new application with Angular version 5.x .

    You can always install other cli versions and create custom softlinks for them to use in future.

提交回复
热议问题