如何使用Angular v4.x安装Angular

编程入门 行业动态 更新时间:2024-10-27 20:29:49
本文介绍了如何使用Angular v4.x安装Angular-CLI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经使用此命令安装了Angular-CLI

I've installed Angular-CLI using this command

npm install -g @angular/cli

但是我已经意识到它已经安装了Angular v5.1.3,但是我需要使用Angular 4.x.

but I've realized that it has installed Angular v5.1.3 but I need to use Angular 4.x.

如何将最新版本的Angular-CLI与最新版本的Angular 4.x一起安装?

How can I install the last version of Angular-CLI with the last version of Angular 4.x?

推荐答案

我认为将cli降级不是一个好主意,因为它们正在修复许多错误.您可以在package.json文件中指定角度.不要依赖您的cli.

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.

首先从cli安装最新版本.然后在package.json的"dependencies"部分中指定所需的版本.例如,如果您想要Angular 4.3.4,则可以编辑package.json文件,例如

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", ........................... ........................... }

还要更改您的devDependencies

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

现在运行npm install

now run npm install

npm install

完成安装后,您应通过ng -v这样的命令查看版本

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

更多推荐

如何使用Angular v4.x安装Angular

本文发布于:2023-10-30 03:46:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541665.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   Angular

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!