Cannot read property 'entries' of undefine

2019-02-22 04:22发布

问题:

I installed latest Angular CLI and was trying to create a new app i am getting the below error. I uninstalled , cleaned cache , cleaned by forcing it , installed , updated npm...restarted computer :-) My versions Angular CLI: 6.1.2 Node: 8.11.3

回答1:

I tried the other suggestions here, but ended up removing and re-installing Node.js and NPM.

Finally did the trick for me.



回答2:

In our case was old package: @angular/pwa Once we update it from: 0.6.8 to 0.7.5 everything started working fine.



回答3:

I reinstalled NodeJS. I deleted node_modules folder from user directory and hit npm install and it started working



回答4:

Hi Shivprasad Koirala,

I had the same problem as you but the solution did not do it for me. Frankly speaking, it is a little bit odd that re-installing node.js fixes your problem because it should not conflict with Angular/CLI but in any case, good for you.

For my case, the solution was a bit different. I had accidentally once tried to create a new project in my username's folder. This was wrong, and I had canceled the procedure but it seems like that it had created one or two things. So in that case the steps are:

  1. Navigate to your username folder by opening windows explorer and typing in the address bar %HomePath%
  2. Check if the file package.json and if the folder node_module exist. If so, you can delete them safely.

If you have a Linux, again you need to navigate to your home directory and delete both those entries.



回答5:

This worked for me:

  1. npm uninstall -g @angular/cli

  2. rm -rf node_modules

  3. delete package-lock.json

  4. Edit package.json devDependencies with these package versions:

    • "@angular/cli": "6.0.8",
    • "@angular/compiler-cli": "6.0.4",
    • "@angular-devkit/build-ng-packagr": "~0.6.8",
    • "@angular-devkit/build-angular": "^0.6.8",
    • "@ngrx/schematics": "6.0.1",
    • "@nrwl/schematics": "6.0.4", (if using nrwl/nx)
    • "ng-packagr": "^3.0.0-rc.2",
    • "typescript": "2.9.2"
  5. npm install



回答6:

Updating all my angular schematic packages worked for me.

Angular CLI: 6.2.3
Node: 8.11.2
OS: darwin x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.8.3
@angular-devkit/core              0.8.3
@angular-devkit/schematics        0.8.3
@angular/cli                      6.2.3
@angular/pwa                      0.7.5
@ngtools/webpack                  6.0.8
@schematics/angular               0.8.3
@schematics/update                0.8.3
rxjs                              5.5.12
typescript                        2.4.2
webpack                           4.8.3


回答7:

I had the same problem after upgrading @angular/cli to version 6.1.5. Downgrading it to 6.0.8 solved problem.

My problem had been occurring during ng g lib ...



回答8:

First of, install node.js from here, and follow the steps below.

To install the Angular CLI:

npm install -g @angular/cli

To create project

ng new my-project //my-project is the name of the project 

Change directory to project folder

cd my-project

To run the Angular project

ng serve


回答9:

This happened to me after updating the project from v6 to v7. However, I missed updating @schematics/angular to a newer version. Apparently, there was some compatibility mismatch that wasn't noted in the package.jsons that caused this issue.

The best way I've found to figure out what the versions of stuff should be is to create a new project with the version of Angular you are trying to use. Once created, look at it's package.json to figure what versions should be compatible with what.