1
votes

I have created a new project but it is not allowing me to ng serve it. It is giving me the 'cannot find module @angular/compiler-cli' error.

I've tried clearing the cache, deleting the node_modules folder from within my project but I am still getting the error. I had previously run npm install -g @angular/cli as well. My package.json file shows @angular/compiler-cli listed as a devDependency. Here's what I get when I try npm install after removing the node_modules folder:

npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor. npm ERR! Unexpected end of JSON input while parsing near '..."dist":{"shasum":"25b'

package.json

    {
  "name": "login-page",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "core-js": "^2.5.4",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.12.1",
    "@angular/cli": "~7.2.1",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.2.2"
  }
}
1
does this folder exist for you? .\node_modules\@angular\compiler-cliAkber Iqbal
Try below steps again..1. npm install npm@latest -g 2.npm install -g @angular/cli 3. npm install update 4. Clean npm cache: npm cache clean --force ...You can check at musttoknow.com/… for creating project in angular using cli...Prashant M Bhavsar
@AkberIqbal I don't currently have the \node_modules\@angular\compiler-cli folder. Sorry for the delayed response.Eddie
when you do ng version from command prompt, what do you get? if you get nothing, then you would need to install angular!Akber Iqbal
Here's an update of what I have tried so far: npm install npm@latest -g, npm remove -g @angular/cli, npm install -g @angular/cli@latest, rm -rf node_modules dist, npm install --save-dev @angular/cli@latest, npm install, npm i nyc (due to: npm WARN deprecated [email protected]: This module is no longer maintained, try this instead: npm WARN deprecated npm i nyc npm WARN deprecated Visit istanbul.js.org/integrations for other alternatives. Then I tried: npm uninstall angular-cli -g, npm uninstall angular-cli --save, npm install @angular-devkit/core --save-dev. Getting same error.Eddie

1 Answers

0
votes

I went back after some time and tried the suggestions that were provided previously and it finally worked. I ended up deleting the package-lock.json file within /node_modules/@angular/compiler-cli. Not 100% sure if it had anything to do with it but did npm install then ng serve and it worked for me. Thank you!