angular - "@angular/compiler-cli"软件包未正确安装错误

标签 angular angular2-routing

我正在尝试使用 ng build 构建我的 angular2 应用程序,但出现以下错误:-

The "@angular/compiler-cli" package was not properly installed. Error: TypeError: Object prototype may only be an Object or null: undefined
Error: The "@angular/compiler-cli" package was not properly installed. Error: TypeError: Object prototype may only be an Object or null: undefined
    at Object.<anonymous> (C:\Official\UI\angular3\node_modules\@ngtools\webpack\src\index.js:14:11)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Official\UI\angular3\node_modules\@angular\cli\tasks\eject.js:10:19)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)

我什至尝试删除现有的node_modules并再次安装,但没有成功。

有什么想法吗?这是我的 package.json:-

"dependencies": {
    "@angular/common": "2.4.6",
    "@angular/compiler": "2.4.6",
    "@angular/core": "2.4.6",
    "@angular/forms": "2.4.6",
    "@angular/http": "2.4.6",
    "@angular/platform-browser": "2.4.6",
    "@angular/platform-browser-dynamic": "2.4.6",
    "@angular/router": "3.0.0-rc.1",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "angular": "^1.6.4",
    "angular2": "^2.0.0-beta.21",
    "angular2-in-memory-web-api": "0.0.15",
    "bootstrap": "^3.3.6",
    "core-js": "^2.4.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "^5.0.0-beta.6",
    "systemjs": "^0.19.27",
    "zone.js": "^0.6.12",
    "ng2-bootstrap": "^1.0.17",
    "ng2-translate": "2.4.1",
    "typescript": "~2.2.0"
  },
  "devDependencies": {
    "@angular/cli": "^1.2.6",
    "@angular/compiler-cli": "^4.3.2",
    "concurrently": "^2.2.0",
    "lite-server": "^2.3.0",
    "typescript": "~2.2.0"
  }

最佳答案

您可以卸载、清理缓存并更新最新版本的 Angular

npm uninstall -g angular-cli @angular/cli
npm cache clean
npm install -g @angular/cli@latest

阅读this了解更多信息

关于angular - "@angular/compiler-cli"软件包未正确安装错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45431525/

相关文章:

javascript - 如何在 Angular 7 中调整 Angular Material 对话框的大小?

angular - oidc-client-js 中的静默更新不起作用

angular - 将 Angular 2 升级到 Angular 4 没有导出成员 'AnimationDriver'

javascript - 如何依次执行父路由和子路由的解析?

javascript - 处理 Angular 2 中动态创建的组件的 @Input 和 @Output

angular - 如何从 ag-grid valueFormatter 调用服务

Angular 2 typescript : Is it possible to pass an interface as a parameter into a function?

authentication - Angular2 auth guard 带有 http 请求和 observables

angular - 在 Angular 2 中处理嵌套订阅的正确方法

angular - 如何在 Angular 2 中创建单例服务?