找不到模块'@ angular/compiler' [英] Cannot find module '@angular/compiler'

查看:346
本文介绍了找不到模块'@ angular/compiler'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行命令npm install -g @ angular/cli,并在尝试运行我的应用程序后说:在终端中找不到模块'@ angular/compiler'.我如何在我的package.json中安装编译器以编译我的应用程序

I run the command npm install -g @angular/cli and after i tried to run my app it says, Cannot find module '@angular/compiler' in the terminal. How can i install the compiler in my package.json in order to compile my application

//package
{
  "name": "Restaurant",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~2.4.9",
    "@angular/compiler": "~2.4.9",
    "@angular/core": "~2.4.9",
    "@angular/forms": "~2.4.9",
    "@angular/http": "~2.4.9",
    "@angular/platform-browser": "~2.4.9",
    "@angular/platform-browser-dynamic": "~2.4.9",
    "@angular/router": "~3.4.9",
    "@types/lodash": "^4.14.50",
    "angular-2-data-table": "^0.1.2",
    "angular2-datatable": "^0.5.2",
    "core-js": "^2.4.1",
    "lodash": "^4.17.4",
    "ng2-date-picker": "^0.2.1",
    "ng2-file-upload": "^1.1.2",
    "ng2-modal": "0.0.25",
    "ng2-pagination": "^2.0.1",
    "ng2-table": "^1.3.2",
    "primeng": "^2.0.1",
    "rxjs": "5.2.0",
    "tinymce": "^4.5.2",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.7"
  },
  "devDependencies": {
    "@angular/cli": "^1.0.0-rc.1",
    "@types/jasmine": "2.2.30",
    "@types/node": "^7.0.5",
    "angular/cli": "1.0.0-beta.28.3",
    "codelyzer": "3.0.0-beta.0",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "3.2.0",
    "karma": "1.5.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.6.0",
    "protractor": "5.1.1",
    "ts-node": "2.1.0",
    "tslint": "4.5.1",
    "typescript": "~2.2.1"
  }
}

推荐答案

尝试删除devDependencies中的"angular/cli": "1.0.0-beta.28.3",没用,并添加它代替"@angular/compiler-cli": "^2.3.1",(因为它是当前版本,否则通过 npm i --save-dev @angular/compiler-cli 进行添加),然后在您的根应用文件夹中运行以下命令:

Try to delete that "angular/cli": "1.0.0-beta.28.3", in the devDependencies it is useless , and add instead of it "@angular/compiler-cli": "^2.3.1", (since it is the current version, else add it by npm i --save-dev @angular/compiler-cli ), then in your root app folder run those commands:

  1. rm -r node_modules(或手动删除node_modules文件夹)
  2. npm cache clean(npm> v5添加--force这样:npm cache clean --force)
  3. npm install
  1. rm -r node_modules (or delete your node_modules folder manually)
  2. npm cache clean (npm > v5 add --force so: npm cache clean --force)
  3. npm install

这篇关于找不到模块'@ angular/compiler'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆