为什么在角度cli更新后出现此错误

时间:2018-07-27 14:25:52

标签: angular angular6

当我运行ng serve时,更新为最新的角度并得到以下错误。我不明白会有什么问题。

Could not find module "@angular-devkit/build-angular" from "F:\\angular\\July\\FinalTest".
Error: Could not find module "@angular-devkit/build-angular" from "F:\\angular\\July\\FinalTest".

    at Object.resolve (C:\Users\User\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\core\node\resolve.js:141:11)
    at Observable.rxjs_1.Observable [as _subscribe] (C:\Users\User\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\archit
ect\src\architect.js:132:40)
    at Observable._trySubscribe (C:\Users\User\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:43:25)
    at Observable.subscribe (C:\Users\User\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:29:22)
    at DoOperator.call (C:\Users\User\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\operators\tap.js:29:23)
    at Observable.subscribe (C:\Users\User\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:24:22)
    at C:\Users\User\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\util\subscribeTo.js:22:31
    at Object.subscribeToResult (C:\Users\User\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\util\subscribeToResult.js:7:
45)
    at MergeMapSubscriber._innerSub (C:\Users\User\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:75
:38)
    at MergeMapSubscriber._tryNext (C:\Users\User\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:72:
14)

ng -v命令显示

    Angular CLI: 6.1.1
Node: 8.11.3
OS: win32 x64
Angular: 6.1.0
... animations, common, compiler, core, forms, http
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------

@angular-devkit/architect       0.7.1 (cli-only)
@angular-devkit/build-angular   <error>
@angular-devkit/core            0.7.1 (cli-only)
@angular-devkit/schematics      0.7.1 (cli-only)
@angular/cli                    <error>
@angular/compiler-cli           <error>
@angular/language-service       <error>
@schematics/angular             0.7.1 (cli-only)
@schematics/update              0.7.1 (cli-only)
rxjs                            6.2.2
typescript                      2.7.2 (cli-only)

我该如何解决。请帮助我某人

1 个答案:

答案 0 :(得分:1)

可能的解决方案是使用“ save-dev”安装devDependencies,对于依赖项也是如此。

npm i --save-dev @angular/cli @angular-devkit/build-angular @angular/compiler @angular/compiler-cli

最后以npm installnpm update结尾。