本文翻译自:Global Angular CLI version greater than local version

When running ng serve I get this warning about my global CLI version being greater than my local version. 运行ng serve此警告,提示我的全局CLI版本大于本地版本。 I don't notice any issues from this warning, but I was wondering if the two versions should be in sync? 我没有从该警告中注意到任何问题,但是我想知道两个版本是否应该同步? Also, Is it necessary to have a local version if you have a global version? 另外,如果您具有全局版本,是否必须具有本地版本?

The warning: 警告:

Your global Angular CLI version (1.1.1) is greater than your local version (1.0.6). 您的全局Angular CLI版本(1.1.1)大于本地版本(1.0.6)。 The local Angular CLI version is used. 使用本地Angular CLI版本。


#1楼

参考:https://stackoom.com/question/30pBC/全局Angular-CLI版本大于本地版本


#2楼

To answer one of the questions, it is necessary to have both a global and local install for the tools to work. 要回答其中一个问题,必须同时在全局和本地安装该工具才能使用。

If you try to run ng serve on an application without the local install of the CLI (global install only), you will get the following error. 如果您尝试在没有本地安装CLI的应用程序上运行ng serve (仅全局安装),则会收到以下错误。

You have to be inside an Angular CLI project in order to use the serve command. 您必须在Angular CLI项目中才能使用serve命令。

It will also print this message: 它还将打印此消息:

Please take the following steps to avoid issues:
"npm install --save-dev @angular/cli@latest"

Run that npm command to update the CLI locally, and avoid the warning that you are getting. 运行该npm命令以在本地更新CLI,并避免收到警告。

Other question: It looks like they do not have to be in sync, but it's probably best that they are in order to avoid any unusual behavior with the tool, or any inconsistencies with the code the tool generates. 其他问题:它看起来像他们不必保持同步,但它可能是最好的,他们是为了避免与工具或工具生成的代码中的任何不一致的任何异常行为。

Why do we need both the global install, and a local install? 为什么我们既需要全局安装又需要本地安装?

The global install is needed to start a new application. 需要全局安装才能启动新的应用程序。 The ng new <app-name> command is run using the global installation of the CLI. ng new <app-name>命令是使用CLI的全局安装运行的。 In fact, if you try to run ng new while inside the folder structure of an existing CLI application, you get this lovely error: 实际上,如果您尝试在现有CLI应用程序的文件夹结构中运行ng new时,将得到以下可爱错误:

You cannot use the new command inside an Angular CLI project. 您不能在Angular CLI项目中使用new命令。

Other commands that can be run from the global install are ng help , ng get/set with the --global option, ng version , ng doc , and ng completion . 这可以从全局来运行其他命令安装在ng helpng get/set--global选项, ng versionng doc ,并ng completion

The local install of the CLI is used after an application has been built. 在构建应用程序之后,将使用CLI的本地安装。 This way, when new versions of the CLI are available, you can update your global install, and not affect the local install. 这样,当新版本的CLI可用时,您可以更新全局安装,而不会影响本地安装。 This is good for the stability of a project. 这有利于项目的稳定性。 Most ng commands only make sense with the local version, like lint , build and serve , etc. 大多数ng命令仅适用于本地版本,例如lintbuildserve等。

According to the CLI GitHub readme , to update the CLI you must update the global and local package. 根据CLI GitHub 自述文件 ,要更新CLI,必须更新全局和本地软件包。 However, I have used the CLI where the global and local version vary without any trouble so far. 但是,到目前为止,我使用的CLI的全局和本地版本有所不同。 If I ever run across an error related to having the global and local CLI versions out of sync, I will post that here. 如果我遇到与使全局和本地CLI版本不同步有关的错误,我将在此处发布。


#3楼

This is how I solved the issue. 这就是我解决问题的方式。

Copy and run these commands 复制并运行这些命令

ng --version
npm install --save-dev @angular/cli@latest
ng --version

#4楼

This works for me: it will update local version to latest 这对我有用:它将本地版本更新为最新版本

npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install

to verify version 验证版本

  ng --version

#5楼

Run the following Command: npm install --save-dev @angular/cli@latest 运行以下命令: npm install --save-dev @angular/cli@latest

After running the above command the console might popup the below message 运行上述命令后,控制台可能会弹出以下消息

The Angular CLI configuration format has been changed, and your existing configuration can be updated automatically by running the following command: ng update @angular/cli Angular CLI配置格式已更改,可以通过运行以下命令来自动更新现有配置:ng update @ angular / cli


#6楼

npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest

Your existing configuration can be updated automatically by running the following command: 您可以通过运行以下命令来自动更新现有配置:

ng update @angular/cli

or: 要么:

npm install

全局Angular CLI版本大于本地版本相关推荐

  1. angular cli全局版本大于本地版本 把本地版本升级方式

    查看 angular 版本  ng version 如出现提示 Your global Angular CLI version (xxx) is greater than your local ver ...

  2. github上的版本和本地版本冲突的解决方法(Updates were rejected because the tip of your current branch is behind)

    github上的版本和本地版本冲突的解决方法(Updates were rejected because the tip of your current branch is behind) 参考文章: ...

  3. Github上的版本和本地版本冲突的解决方法

    Github上的版本和本地版本冲突的解决方法 远程和本地版本冲突 情景: 在github上创建项目,然后本地git init 然后没有git pull -f --all 然后git add .  | ...

  4. Linux安装指定版本Angular Cli

    环境准备: 1.安装nodejs 不同版本Angular Cli需要安装不同版本的nodejs,本文安装v10.16.0版本的nodejs,可以支持7.x版本的Angular Cli.由于开发需要使用 ...

  5. NgRx 和 Angular CLI 版本不一致的错误

    我最近试图用 Angular Schematics 安装基于 Spartacus 4.0.1 的 Storefront,yarn install 之后执行 yarn start,遇到如下错误消息: E ...

  6. Angular CLI版本问题(Your global Angular CLI version (12.2.7) is greater than your local version (9.0.3))

    说我全局安装的版本是12.2.7,本地安装的版本是9.0.3,那么我应该卸载本地版本? 最后还是没解决

  7. npm-卸载并安装指定版本Angular CLI以及报错(npm ERR! Error: EACCES: permission denied)

    今天想,装angular5,所以装了angular-cli1.7.4版本,结果报错了,,, 1.卸载之前的版本 npm uninstall -g @angular/cli 2.清除缓存,确保卸载干净 ...

  8. 如何安装 Angular CLI 并且检查 CLI 的版本

    想在系统中安装 Angular CLI ,如何进行安装并且如何检查 CLI 的版本? 可以使用命令: npm install -g @angular/cli 进行安装. 使用命令 ng version ...

  9. Angular5.0之 安装指定版本Angular CLI

    我们可能会发现按照网上的方式下载安装后,使用Angular CLI生成的项目并不是我们想要的Angular的版本,因为在我们没有指定安装版本的前提下,默认会下载最新的版本安装,然而不同的Angular ...

最新文章

  1. pytorch遇见RuntimeError: CUDA out of memory的解决
  2. hdu 2065DP
  3. mysql back blog_mysql的备份Xtrabackup
  4. [doc文档]widows apache+myql+php
  5. exchange 2010 relay设定
  6. (转)如何判断一个人是否具有管理的潜力?
  7. 《Microsoft SQL Server入门教程》第01篇 SQL Server 简介
  8. Unity IAP接入google支付文档(2022年最新)
  9. php 硬盘序号_关于取硬盘序列号
  10. 其他 - 所有中文字 附 拼音
  11. 6寸相纸怎么排版两寸照片
  12. 【IoT】 产品设计:结构设计流程
  13. 二叉查找树(BST)专题
  14. 语音识别——kaldi - Online Audio Server(服务器客户端建立方法-旧版在线解码)
  15. 学完python可以从事哪些工作?
  16. 计算机图形学实验一 《MFC绘图基础》
  17. java家庭记账代码_Java的家庭记账本程序(B)
  18. 可汗学院学习总结(一)
  19. 深入解析go依赖注入库go.uber.org/fx
  20. oracle的opm,Oracle EBS OPM 发放生产批

热门文章

  1. 在PaaS上构建SaaS应用程序需要注意什么
  2. SqlSession接口和Executor
  3. 如何分析android的OOM,与java静态代码分析工具
  4. zabbix如何实现微信报警
  5. android httpClient 支持HTTPS的访问方式
  6. 12种JavaScript MVC框架之比较
  7. asp.net core刷新css缓存
  8. 【Android Studio安装部署系列】十九、Android studio使用SVN
  9. Centos7搭建LAMP+Typecho博客
  10. ftp 530 This FTP serveris anonymous only,