如何在 angular cli 6.0.1 中创建 angular 5 项目 [英] How to create angular 5 project in angular cli 6.0.1

查看:30
本文介绍了如何在 angular cli 6.0.1 中创建 angular 5 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 angular cli 版本是 6.0.1node 版本是 8.11.1.

如何创建或添加 angular 5 的新项目.

How to create or add a new project of angular 5.

如果我使用 ng new [project_name] 那么项目正在下载 angular 6.

If I use ng new [project_name] then the project is downloading that is of angular 6.

推荐答案

我也偶然发现了这种情况.
这是我的解决方案.

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

不幸的是,我们受 CLI 的支配,这是创建新的 Angular 项目脚手架的最佳方式.
考虑到 ng new {app_name} 不支持版本标志.
我们的目标是安装正确的 CLI 版本.

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. 创建一个新文件夹:mkdir ng-5-cli &&cd ng-5-cli
  2. 初始化 NPM npm init
  3. 安装旧的 Angular CLI:npm i @angular/cli@1.7.4 --save-dev
  4. 出于某种原因,ng 编译器现在假定这是一个 angular 项目目录,并且不允许在此处运行 ng new.
  5. 退出当前目录:cd ..
  6. 使用步骤 1 中目录中 Angular cli 的绝对路径.

例如/ng-5-cli/node_modules/.bin/ng new some-ng5-app

这应该使用 Angular 版本 5.x 创建一个新应用程序.

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

您始终可以安装其他 cli 版本并创建自定义软链接以供将来使用.

这篇关于如何在 angular cli 6.0.1 中创建 angular 5 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆