【问题标题】:Installing dependencies with npm-peer-dependencies使用 npm-peer-dependencies 安装依赖项
【发布时间】:2022-02-15 00:27:43
【问题描述】:

我正在尝试使用 npm install 为运行 Angular 11 的小项目安装所需的 node_modules

我的目标是让项目从 GitHub 下载后在本地运行。我已经安装了最新版本的 Angular CLI。 运行安装命令后,我尝试了npm start

我期待在运行安装和启动命令后能够在本地运行项目。 但是,我在运行 install 命令后得到的实际结果是以下错误列表:

> ng serve

An unhandled exception occurred: Cannot find module '@angular/compiler'
Require stack:

\node_modules\@angular\compiler-cli\index.js
\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js
\node_modules\@ngtools\webpack\src\index.js
\node_modules\@angular-devkit\build-angular\src\webpack\configs\typescript.js
\node_modules\@angular-devkit\build-angular\src\webpack\configs\index.js
\node_modules\@angular-devkit\build-angular\src\browser\index.js
\node_modules\@angular-devkit\build-angular\src\dev-server\index.js
\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
\node_modules\@angular-devkit\architect\node\index.js
\node_modules\@angular\cli\models\architect-command.js
\node_modules\@angular\cli\commands\serve-impl.js
\node_modules\@angular-devkit\schematics\tools\export-ref.js
\node_modules\@angular-devkit\schematics\tools\index.js
\node_modules\@angular\cli\utilities\json-schema.js
\node_modules\@angular\cli\models\command-runner.js
\node_modules\@angular\cli\lib\cli\index.js
\node_modules\@angular\cli\lib\init.js
\node_modules\@angular\cli\bin\ng

See "angular-errors.log" for further details.

npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file C:\WINDOWS\system32\cmd.exe
npm ERR! errno ENOENT
npm ERR! `ng serve`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the @0.0.16 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

问题是这个 Angular 项目也有对等依赖。我安装了npm-install-peers 包,但似乎之后简单地运行npm install 不会安装所需的对等依赖项。 接下来我应该怎么做才能在本地安装这个 Angular 项目?

【问题讨论】:

    标签: node.js angular npm dependencies


    【解决方案1】:

    您面临的问题可能是因为您的计算机上未全局安装 angular cli 或 npm-peer-dependencies。 您应该采取的步骤是确保它们是全局安装的。 要在全球范围内安装软件包,您需要运行 npm install -g <package_name> npm docs link

    对于 Angular cli,您应该运行 npm i -g @angular/cli@11.2.15npm install -g npm-peer-dependencies。 然后运行npm start

    【讨论】:

      猜你喜欢
      • 2021-07-15
      • 2016-03-14
      • 1970-01-01
      • 2017-04-14
      • 1970-01-01
      • 2021-04-21
      • 2016-06-23
      • 2020-12-28
      • 2018-01-17
      相关资源
      最近更新 更多