angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.98k forks source link

@angular/compiler-cli package was not properly installed; cannot find module @angular/compiler #7207

Closed prahaladbelavadi closed 7 years ago

prahaladbelavadi commented 7 years ago

Repro steps.

ng serve

The log given by the failure.


\The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler'
Error: The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler'
    at Object.<anonymous> (C:\Users\praha\AppData\Roaming\npm\node_modules\@angular\cli\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\praha\AppData\Roaming\npm\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)

Desired functionality.

Start server

Mention any other details that might be useful.

  1. tried uninstalling angular package and reinstalling it
  2. running node version 6.11
  3. it says typescript is required, but doesn't install it
  4. on meeting dependencies separately also, it doesn't download @angular/compiler

image image

filipesilva commented 7 years ago

Fixed by https://github.com/angular/angular-cli/pull/7033.

We had a bug where ng new didn't wait for the packages to install. Newer versions don't suffer from this. Removing node_modules and running npm install should clear it.

moezkorkmaz commented 7 years ago

I experience the same problem.

> ng serve
Unable to find "@angular/cli" in devDependencies.

Please take the following steps to avoid issues:
"npm install --save-dev @angular/cli@latest"

Executing npm install --save-dev @angular/cli@latest did not help.

filipesilva commented 7 years ago

@moezkorkmaz you're experiencing something different. This issue was about @angular/compiler-cli not being in installed, but yours is about @angular/cli not being in the dependencies. Please open a new issue for yours.

ChuckkNorris commented 7 years ago

EDIT: Resolved the issue by updating the @angular/cli to 1.2.6 and recreating the project from scratch.

Had this same issue. Deleted /node_modules and re-ran npm install with no success. Any other ideas?

compiler-cli error

"dependencies": {
    "@angular/animations": "^4.3.2",
    "@angular/cdk": "^2.0.0-beta.8",
    "@angular/common": "4.3.2",
    "@angular/compiler": "4.3.2",
    "@angular/core": "4.3.2",
    "@angular/forms": "4.3.2",
    "@angular/http": "^4.3.2",
    "@angular/material": "^2.0.0-beta.8",
    "@angular/platform-browser": "4.3.2",
    "@angular/platform-browser-dynamic": "4.3.2",
    "@angular/router": "4.3.2",
    "core-js": "^2.4.1",
    "hammerjs": "^2.0.8",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.2.1",
    "@angular/compiler-cli": "4.3.2",
    "@angular/language-service": "^4.0.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.0.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.0.4",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }

Node Version: 8.1.2 CLI version: 1.2.1 NPM Version: 5.0.3

Tsakirogf commented 7 years ago

My exp in case: I have installed the proper version of Ang cli. package.json ->"devDependencies": { "@angular/cli": "1.2.6", And still I had the same error. However probably because I use λcmder.exe on Windows platform , a RESTART was needed. After this everything work properly with no other action required.

jmurphy45 commented 7 years ago

I have a similar issue I believe when I run ng build I get this error:

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> (/Users/jmurphy/Documents/workspace/fp/node_modules/@ngtools/webpack/src/index.js:14:11) at Module._compile (module.js:569:30) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:503:32) at tryModuleLoad (module.js:466:12) at Function.Module._load (module.js:458:3) at Module.require (module.js:513:17) at require (internal/module.js:11:18) at Object.<anonymous> (/Users/jmurphy/Documents/workspace/fp/node_modules/@angular/cli/tasks/eject.js:10:19) at Module._compile (module.js:569:30) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:503:32) at tryModuleLoad (module.js:466:12) at Function.Module._load (module.js:458:3) at Module.require (module.js:513:17) at require (internal/module.js:11:18)

I tried deleting node_modules and reinstalling without any luck

ashokmachineni commented 7 years ago

I just changed to "@angular/compiler-cli": "^4.3.2" from "@angular/compiler-cli": "^4.0.0" in devDependencies in package.json file.

It worked for me

Joryiqfy commented 7 years ago

Yeah I am getting the same error. @angular/compiler-cli is updated locally and globally and I tried with a new app. And removed the node modules file.

jack007spark commented 7 years ago

I was also facing the same problem, But after restarting my system it all working fine.

chrustkiran commented 7 years ago

restarting means ? so you are saying ng serve command is working fine???

zarkob commented 7 years ago

I confirm, restart worked well for me as well

yogeshshende85 commented 7 years ago

Restarting the system also works for fine.

pkaiche commented 7 years ago

When i run npm install in my new project to get dependencies there are no errors. Packages are added successfully. But when i run ng serve i am getting below error:

F:\my-apps\material-dashboard-angular>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. (F:\my-apps\material-dashboard-angular\node_modules\@ngtools\webpack\src\index.js:14:11) at Module._compile (module.js:573:30) at Object.Module._extensions..js (module.js:584:10) at Module.load (module.js:507:32) at tryModuleLoad (module.js:470:12) at Function.Module._load (module.js:462:3) at Module.require (module.js:517:17) at require (internal/module.js:11:18) at Object. (F:\my-apps\material-dashboard-angular\node_modules\@angular\cli\tasks\eject.js:10:19) at Module._compile (module.js:573:30) at Object.Module._extensions..js (module.js:584:10) at Module.load (module.js:507:32) at tryModuleLoad (module.js:470:12) at Function.Module._load (module.js:462:3) at Module.require (module.js:517:17) at require (internal/module.js:11:18)

I have done the same on my own laptop & it worked fine there. But when i am doing the same steps on my companies system i am getting this error. I am using net setter to avoid proxy error. I have tried this with both System administrator login & my own login. I have also changed Environment Variable setting to set PATH value to nodejs folder; npm folder.

Can anyone help me out with this. I am stuck in this since a week & have gone through a lot of blogs but of no help. Any help s deeply appreciated. Thanks in advance.

chrustkiran commented 7 years ago

I think you ran ng build command that is why its showing this error, delete dist folder and try run ng serve

didorg commented 7 years ago

That is because when uploading the project to github does not upload with the folder "node_modules"(177,1 MB) -> Can not find module '@ angular / compiler-cli'. When you clone it does not bring you this folder and gives that error. The solution is to generate a new project and take this folder or take it from another project that we have.

ideamanplatform commented 7 years ago

I managed to get mine fixed by first running the npm install "whatever-it-says-i-am-missing" and then i ran npm update and i got a new hint from cli to change my environment configurations.

ideamanplatform commented 7 years ago

But I think first one needs to delete the node_modules directory, run npm install then do the above step.

mohammed-aladi commented 7 years ago

first : npm install -g @angular/cli 2 : ng new "your project name" 3 : ng serve : erro >>> do not wrray 4 : npm install @angular/compiler-cli 5 : npm install typescript 6 : npm install @angular/cli

it is work !!

Dahdoul commented 7 years ago

fixed the error by renaming the directory from #Projects to Project. so I assume the issue that the directory contained special characters. :)

I get similar error when I run ng serve. I did the following steps but nothing worked:-

Error

ERROR in Error: Could not resolve "/home/dahdoul/" from "/home/dahdoul/". at _resolveModule (/home/dahdoul/#Projects/myapp/node_modules/@angular/compiler-cli/src/ngtools_impl.js:79:15) at Object.listLazyRoutesOfModule (/home/dahdoul/#Projects/myapp/node_modules/@angular/compiler-cli/src/ngtools_impl.js:47:26) at Function.NgTools_InternalApi_NG_2.listLazyRoutes (/home/dahdoul/#Projects/myapp/node_modules/@angular/compiler-cli/src/ngtools_api.js:91:39) at AotPlugin._getLazyRoutesFromNgtools (/home/dahdoul/#Projects/myapp/node_modules/@ngtools/webpack/src/plugin.js:207:44) at _donePromise.Promise.resolve.then.then.then.then.then (/home/dahdoul/#Projects/myapp/node_modules/@ngtools/webpack/src/plugin.js:443:24) at at process._tickCallback (internal/process/next_tick.js:188:7)

Angular cli version

@angular/cli: 1.4.1 node: 8.4.0 os: linux x64 @angular/animations: 4.3.6 @angular/common: 4.3.6 @angular/compiler: 4.3.6 @angular/core: 4.3.6 @angular/forms: 4.3.6 @angular/http: 4.3.6 @angular/platform-browser: 4.3.6 @angular/platform-browser-dynamic: 4.3.6 @angular/router: 4.3.6 @angular/cli: 1.4.1 @angular/compiler-cli: 4.3.6 @angular/language-service: 4.3.6 typescript: 2.3.4

gion commented 7 years ago

I had a similar issue: when I ran ng-serve I got the same error that informed me that angular cli is not properly installed. My issue was that the project's devDependencies weren't installing. I had the global NODE_ENV variable set to production from a different project, which forces npm to ignore devDependencies when installing.
After changing that variable's value and running npm i, everything is working as expected. Hope this helps anyone else!

nikunjkansara commented 7 years ago

I had also similar issue, I have followed the steps First, npm install -g @angular/cli create new project with ng new hero-app After the go inside the project folder and run server ng serve and open browser and run http://localhost:4200

This is work for me.. Hope same thing work for you as well

Vasundhara-vasu commented 7 years ago

Hi All,

I am getting below "error message" in "eclipse terminal" when i type "ng help"

The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module 'rxjs/symbol/observable'

Can any one suggest me what to do now , how to overcome this issue.

I am using below data 1.Node -- v6.11.3 2.i installed anuglar cli using "npm install -g angular-cli" command 3.i created "angular project" in "eclipse" and now i entered "ng help" command in "eclipse terminal" it is displaying

The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module 'rxjs/symbol/observable' Error: The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module 'rxjs/symbol/observable' at Object. (C:\Users\agudla\AppData\Roaming\npm\node_modules\angular-cli\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. (C:\Users\agudla\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-configs\typescript.js:3: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) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (C:\Users\agudla\AppDa

sreekanth1319 commented 7 years ago

I came across the same error.When I checked my code there is some error with my .angular-cli.json code.The error is I forgot to close the braces.

leonlovett commented 7 years ago

I was getting the same error and was able to solve it by reinstalling angular-cli locally. npm i @angular/cli

Maneeshkc commented 7 years ago

To resolve the issue, you need to navigate to the correct folder. eg: cd sampleapplication image

musmanalibaloch commented 7 years ago

The biggest mistake which people do, is that they are not in the project folder , ng serve in that case fails, because it fails to find angular project. So make sure you are in right folder

Vasundhara-vasu commented 7 years ago

Thanks for your replies.

ng help is working for me now ,

i move to the correct project folder and run the command

amlang commented 6 years ago

If this problem occurs in an Angular 4.4+ environment, it can help if you reinstall @angular/compiler npm install --save-dev @angular/compiler

My environment that works:
@angular/cli: 1.4.9
node: 8.1.4
os: darwin x64
@angular/common: 4.4.6
@angular/core: 4.4.6
@angular/forms: 4.4.6
@angular/http: 4.4.6
@angular/platform-browser: 4.4.6
@angular/platform-browser-dynamic: 4.4.6
@angular/router: 4.4.6
@angular/cli: 1.4.9
@angular/compiler: 4.4.6
@angular/compiler-cli: 4.4.6
typescript: 2.3.4
shubham-aneja commented 6 years ago

Restarting did solve my issue

nishav11 commented 6 years ago

first : npm install -g @angular/cli 2 : ng new "your project name" 3 : ng serve : erro >>> do not wrray 4 : npm install @angular/compiler-cli 5 : npm install typescript 6 : npm install @angular/cli

did all the steps above as suggested by @omanigaming npm install was not installing all the packages so ran 'npm install --force' and it worked.

Thanks :)

ArnoldKrumins commented 6 years ago

for me I installed 'angular2-highcharts' and my project was getting the same issue. I uninstalled and it worked again. So maybe check your last npm install before it stopped working

sarancruzer commented 6 years ago

Hi i am also getting this error this is my package.json file

{ "name": "@coreui/angular", "version": "1.0.0", "description": "", "author": "", "url": "http://coreui.io", "copyright": "Copyright 2017 creativeLabs Łukasz Holeczek", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular-devkit/schematics": "0.0.40", "@angular/animations": "^4.4.5", "@angular/common": "4.4.3", "@angular/compiler": "4.4.3", "@angular/core": "4.4.3", "@angular/forms": "4.4.3", "@angular/http": "4.4.3", "@angular/platform-browser": "4.4.3", "@angular/platform-browser-dynamic": "4.4.3", "@angular/router": "4.4.3", "@angular/upgrade": "4.4.3", "angular2-datatable": "^0.6.0", "angular2-serverpagination-datatable": "^1.5.4", "angular2-toaster": "^4.0.1", "chart.js": "2.7.0", "core-js": "2.5.1", "font-awesome": "^4.7.0", "moment": "2.18.1", "ng2-charts": "1.6.0", "ng2-validation": "^4.2.0", "ngx-bootstrap": "1.9.3", "rxjs": "5.4.3", "simple-line-icons": "^2.4.1", "toastr-ng2": "^4.1.1", "ts-helpers": "1.1.2", "zone.js": "0.8.17" }, "devDependencies": { "@angular/cli": "^1.6.0", "@angular/compiler-cli": "4.4.3", "@types/jasmine": "2.6.0", "@types/node": "8.0.28", "codelyzer": "3.2.0", "jasmine-core": "2.8.0", "jasmine-spec-reporter": "4.2.1", "karma": "1.7.1", "karma-chrome-launcher": "2.2.0", "karma-cli": "1.0.1", "karma-coverage-istanbul-reporter": "1.3.0", "karma-jasmine": "1.1.0", "karma-jasmine-html-reporter": "0.2.2", "protractor": "5.1.2", "ts-node": "3.3.0", "tslint": "5.7.0", "typescript": "^2.6.2" }, "engines": { "node": ">= 6.9.0", "npm": ">= 3.0.0" } }

asfo commented 6 years ago

If you're still facing this issue, do the following (inside the project folder):

Hope it helps

Benyaminrmb commented 6 years ago

You just need to reinstall the installation process

  1. npm install -g @angular/cli

(In your 'root files' (not in angular files ) )

  1. ng new my-app

Not in angular files --- If you have already created this file change the name like 'my-app1' or 2 ... )

  1. ng serve

(In your 'Angular files' )

Its works for me !`

FollyHerman commented 6 years ago

Hi there. I follow asfo steps and that work for me. Now I am going to build great ng app. :)

albertotorresfoltyn commented 6 years ago

This is why 3 years ago I migrated mostly to react... (Happened to me today)

Zuckjet commented 6 years ago

same error, help please

rahul6612 commented 5 years ago

try this

  1. npm uninstall angular-cli
  2. npm install @angular/cli --save-dev
apaluri18 commented 5 years ago

If you're still facing this issue, do the following (inside the project folder):

* Delete your `node_modules` dir

* Delete your `package-lock.json`

* Run `npm install`

* Run `npm link`

* Done

Hope it helps

Thank you npm link is the key to solve this issue.

scriptlogicusa commented 5 years ago

I too spent many hours trying to resolve the issue of "npm start" not working. One of the many errors I received was (Data path ".builders['app-shell']" should have required property 'class'). The toughest error I encountered was the one regarding ELIFECYCLE and described here (https://github.com/facebook/create-react-app/issues/5980).

After many failed tries of others' suggestions, the instructions from this link (https://update.angular.io/#7.0:8.0) ended up finally solving my problem.

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.