当运行ng serve时,我得到一个关于我的全局CLI版本大于本地版本的警告。我没有注意到这个警告有任何问题,但我想知道两个版本是否应该同步?另外,如果你有一个全局版本,是否有必要有一个本地版本?

警告:

你的Angular CLI全局版本(1.1.1)比你的本地版本(1.0.6)更高。使用的是Angular CLI的本地版本。


当前回答

在版本中

NPM install——save-dev @angular/cli@latest

关闭命令提示符并再次打开 ng版本 如果你的PowerShell不识别ng命令,在你的PowerShell运行这个命令:

Set-ExecutionPolicy -scope currentuser -executionpolicy remotessigned

其他回答

在版本中

NPM install——save-dev @angular/cli@latest

关闭命令提示符并再次打开 ng版本 如果你的PowerShell不识别ng命令,在你的PowerShell运行这个命令:

Set-ExecutionPolicy -scope currentuser -executionpolicy remotessigned

NPM install——save-dev @angular-devkit/build-angular - did帮助ng更新了@angular/cli -> did创建了angular。Json和其他更新。

收集已安装的依赖项… 发现58个依赖项。

 ** Executing migrations for package '@angular/cli' **
            Updating karma configuration
            Updating configuration
            Removing old config file (.angular-cli.json)
            Writing config file (angular.json)
            Some configuration options have been changed, please make sure to update any  npm scripts which you may have modified. DELETE .angular-cli.json CREATE angular.json (4394 bytes) CREATE browserslist (429 bytes) UPDATE karma.conf.js (993 bytes) UPDATE public/tsconfig.spec.json (295 bytes) UPDATE package.json (2618 bytes) UPDATE tsconfig.json (437 bytes) UPDATE tslint.json (3135 bytes) UPDATE public/polyfills.ts (587 bytes) UPDATE public/tsconfig.app.json (199 bytes) npm WARN @angular/core@5.2.9 requires a peer of zone.js@^0.8.4 but none is installed. You must install peer dependencies yourself.

做这些事

npm install --save-dev @angular/cli@latest
npm audit fix
npm audit fix --force

更新Angular CLI的工作区(Local)

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

注意:如果安装正确,请确保使用' -g '命令安装全局版本

npm install -g @angular/cli@latest

运行Update命令获取需要升级的所有依赖项的列表

ng update

对每个Angular核心包运行update命令,如下所示

ng update @angular/cli @angular/core

然而,我不得不添加' -force '和' -allow-dirty '标志来解决所有其他悬而未决的问题

ng update @angular/cli @angular/core --allow-dirty --force

我英语说得不流利

但如果我理解了这个问题,是不是项目的本地CLI版本比全局CLI版本要旧?

您想使用全局更新而不是本地旧的吗?

如果是的话,在项目目录npm link @angular/cli中运行一个非常简单的方法就足够了

更多相关主题请访问:https://docs.npmjs.com/cli/link