问题
I have encountered the following errors when updating the version of Angular Cli to 8
.
Could not find module "@angular-devkit/build-angular" from "C:\\Users\\AGT\\Desktop\\central8\\client".
Error: Could not find module "@angular-devkit/build-angular" from "C:\\Users\\AGT\\Desktop\\central8\\client".
at Object.resolve (C:\Users\AGT\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\core\node\resolve.js:151:11)
at WorkspaceNodeModulesArchitectHost.resolveBuilder (C:\Users\AGT\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js:31:40)
at ServeCommand.initialize (C:\Users\AGT\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:135:55)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
回答1:
If you are upgrading to Angular 8, you should ensure your Angular packages are safely updated to the current stable version by running the following command
ng update
Otherwise, you can try to manually update the @angular/cli
and core framework package manually.
ng update @angular/cli @angular/core
Alternatively, you can directly use npm to install/update it.
npm install --save-dev @angular-devkit/build-angular
The step-by-step Angular upgrade guide can be found here.
回答2:
npm uninstall -g @angular/cli
npm cache verify
npm install -g @angular/cli@latest
Then in your Local project package:
rm -rf node_modules dist
npm install --save-dev @angular/cli@latest
npm i
ng update --all --force
npm install --save-dev @angular-devkit/build-angular
Your app has now been upgrade to the latest version
来源:https://stackoverflow.com/questions/56373422/upgrade-angular-cli-to-8