Cannot find module '@angular/compiler'

Angular

Angular Problem Overview


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"
  }
}

Angular Solutions


Solution 1 - Angular

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 (or delete your node_modules folder manually)
  2. npm cache clean (npm > v5 add --force so: npm cache clean --force)
  3. npm install

Solution 2 - Angular

I just run npm install and then ok.

Solution 3 - Angular

Try this

  1. npm uninstall angular-cli
  2. npm install @angular/cli --save-dev

Solution 4 - Angular

Uninstall the Angular CLI and install the latest version of it.

npm uninstall angular-cli

npm install --save-dev @angular/cli@latest

Solution 5 - Angular

In my case this was required:
npm install @angular/compiler --save
npm install @angular/cli --save-dev

Solution 6 - Angular

This command is working fine for me ubuntu 16.04 LTS:

npm install --save-dev @angular/cli@latest

Solution 7 - Angular

Just to add to this. You will get this error too, when you are running ng serve not from within your project folder. So always make sure your bash runs from your project folder.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLiska LiskorView Question on Stackoverflow
Solution 1 - AngularSeleMView Answer on Stackoverflow
Solution 2 - AngularLasith NiroshanView Answer on Stackoverflow
Solution 3 - AngularRahul VermaView Answer on Stackoverflow
Solution 4 - AngularChamila MaddumageView Answer on Stackoverflow
Solution 5 - AngularMartin SchneiderView Answer on Stackoverflow
Solution 6 - AngularAkalyvanView Answer on Stackoverflow
Solution 7 - AngularKarlView Answer on Stackoverflow