我在角度9 cli上运行了ng serve
命令,但出现这些错误:
发生未处理的异常:找不到模块'@ angular-devkit / build-angular / package.json'需要堆栈:-C:\ Users \ hp \ AppData \ Roaming \ nvm \ v12.16.3 \ node_modules @ angular \ cli \ node_modules @ angular-devkit \ architect \ node \ node-nodes-modules-architect-host.js-C:\ Users \ hp \ AppData \ Roaming \ nvm \ v12.16.3 \ node_modules @ angular \ cli \ node_modules @ angular-devkit \ architect \ node \ index.js-C:\ Users \ hp \ AppData \ Roaming \ nvm \ v12.16.3 \ node_modules @ angular \ cli \ models \ architect-command.js-C:\ Users \ hp \ AppData \ Roaming \ nvm \ v12.16.3 \ node_modules @ angular \ cli \ commands \ serve-impl.js-C:\ Users \ hp \ AppData \ Roaming \ nvm \ v12.16.3 \ node_modules @ angular \ cli \ node_modules @ angular-devkit \ schematics \ tools \ export-ref.js-C:\ Users \ hp \ AppData \ Roaming \ nvm \ v12.16.3 \ node_modules @ angular \ cli \ node_modules @ angular-devkit \ schematics \ tools \ index.js-C:\ Users \ hp \ AppData \ Roaming \ nvm \ v12.16.3 \ node_modules @ angular \ cli \ utilities \ json-schema.js-C:\ Users \ hp \ AppData \ Roaming \ nvm \ v12.16.3 \ node_modules @ angular \ cli \ models \ command-runner.js-C:\ Users \ hp \ AppData \ Roaming \ nvm \ v12.16.3 \ node_modules @ angular \ cli \ lib \ cli \ index.js-C:\ Users \ hp \ AppData \ Roaming \ nvm \ v12.16.3 \ node_modules @ angular \ cli \ lib \ init.js-C:\ Users \ hp \ AppData \ Roaming \ nvm \ v12.16.3 \ node_modules @ angular \ cli \ bin \ ng有关信息,请参见“ C:\ Users \ hp \ AppData \ Local \ Temp \ ng-gK2xYm \ angular-errors.log”进一步的细节。
安装@ angular-devkit / build-angular作为开发依赖项
npm install --save-dev @angular-devkit/build-angular
或
yarn add @angular-devkit/build-angular --dev
尝试一下,
删除package-lock.json
文件,node_modules
文件夹。删除后,再次运行npm install
。
似乎缺少npm安装。删除package-lock.json,node_modules文件夹并首先运行npm install。