【问题标题】:ng-serve failed with yarn as package managerng-serve 以 yarn 作为包管理器失败
【发布时间】:2018-03-16 04:29:20
【问题描述】:

我将yarn 设置为angular-cli 的包管理器,当我运行ng new my-app 时它成功完成

Installing packages for tooling via yarn.
Installed packages for tooling via yarn.

但是当我运行ng-serve 时,我收到以下错误消息:

The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'Error: The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'
    at Object.<anonymous> (C:\Users\Hadi\AppData\Local\Yarn\config\global\node_modules\@ngtools\webpack\src\index.js:14:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Hadi\AppData\Local\Yarn\config\global\node_modules\@angular\cli\tasks\eject.js:10:19)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Hadi\AppData\Local\Yarn\config\global\node_modules\@angular\cli\models\webpack-configs\styles.js:6:17)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

我有angular-clie 1.4.4 版和yarn 1.1.0 版

【问题讨论】:

  • 尝试使用 yarn start 代替 ng serve 来运行开发项目

标签: angular npm angular-cli package-managers yarnpkg


【解决方案1】:

执行以下步骤:

npm install -g yarn
ng set --global packageManager=yarn

使用

运行项目
yarn start

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2022-07-15
  • 2019-02-08
  • 1970-01-01
  • 2018-06-10
  • 1970-01-01
  • 2017-06-07
  • 1970-01-01
  • 2022-11-11
相关资源
最近更新 更多