How to install Angular-CLI with Angular v4.x

前端 未结 6 750
后悔当初
后悔当初 2020-12-06 07:31

I\'ve installed Angular-CLI using this command

npm install -g @angular/cli

but I\'ve realized that it has installed Angular v5.1.3 but I ne

6条回答
  •  孤街浪徒
    2020-12-06 08:14

    I think downgrade your cli is not good idea becuase they are fixing lots of bug. You can specific your angular in package.json file. don't depend on your cli.

    Edit

    First install latest version from your cli. Then Specify the version you want in the 'dependencies' section of your package.json. For example if you want Angular 4.3.4 then you can edit you package.json file like

    "dependencies": {
        "@angular/animations": "^4.3.4",
        "@angular/common": "^4.3.4",
        "@angular/compiler": "^4.3.4",
        "@angular/core": "^4.3.4",
        "@angular/forms": "^4.3.4",
        "@angular/http": "^4.3.4",
        "@angular/platform-browser": "^4.3.4",
        "@angular/platform-browser-dynamic": "^4.3.4",
        "@angular/router": "^4.3.4",
         ...........................
         ...........................
        }
    

    Also change your devDependencies

        "devDependencies": {
          "@angular/compiler-cli": "^4.3.4",
          "@angular/language-service": "^4.3.4",
          .............
        }
    

    now run npm install

      npm install
    

    After finishing install you should see your version by ng -v command like this

    Angular CLI: 1.6.3
    Node: 9.3.0
    OS: linux x64
    Angular: 4.4.6
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router, tsc-wrapped
    
    @angular/cli: 1.6.3
    @angular-devkit/build-optimizer: 0.0.38
    @angular-devkit/core: 0.0.25
    @angular-devkit/schematics: 0.0.48
    @ngtools/json-schema: 1.1.0
    @ngtools/webpack: 1.9.3
    @schematics/angular: 0.1.13
    @schematics/schematics: 0.0.13
    typescript: 2.4.2
    webpack: 3.10.0
    

提交回复
热议问题