Solvedangular cli Creating new component shows error:TypeError: core_1.PriorityQueue is not a constructor


Angular CLI: 1.6.4
Node: 8.9.4
OS: linux x64
Angular: 5.2.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.4
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.4
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0

Repro steps

  • Running command ng g c component

Observed behavior

core_1.PriorityQueue is not a constructor
TypeError: core_1.PriorityQueue is not a constructor
    at new TaskScheduler (/home/praveen/academeics/node_modules/@angular-devkit/schematics/src/engine/task.js:20:23)
    at SchematicEngine.createContext (/home/praveen/academeics/node_modules/@angular-devkit/schematics/src/engine/engine.js:81:31)
    at (/home/praveen/academeics/node_modules/@angular-devkit/schematics/src/engine/schematic.js:35:38)
    at Promise (/home/praveen/academeics/node_modules/@angular/cli/tasks/schematic-run.js:73:23)
    at new Promise (<anonymous>)
    at (/home/praveen/academeics/node_modules/@angular/cli/tasks/schematic-run.js:72:16)
    at (/home/praveen/academeics/node_modules/@angular/cli/commands/generate.js:161:33)
    at resolve (/home/praveen/academeics/node_modules/@angular/cli/ember-cli/lib/models/command.js:261:20)
    at new Promise (<anonymous>)
    at Class.validateAndRun (/home/praveen/academeics/node_modules/@angular/cli/ember-cli/lib/models/command.js:240:12)

Desired behavior

Component should be created

###Deleting node_modules allowed creation of component and installing it again produces the above bug.

17 Answers

✔️Accepted Answer

I had the same issue and solved it by adding devkit-core in version 0.0.29 to my devDependencies

"devDependencies": {
    "@angular-devkit/core": "0.0.29",

or using with npm i -D @angular-devkit/core@0.0.29

Other Answers:

Same here... Fixed it by adding "@angular-devkit/core": "0.0.29" to package.json for angular 5 using npm i -D @angular-devkit/core@0.0.29 command

I was able to resolve this same error by updating angular-cli to the latest version

npm remove -g @angular/cli
npm install -g @angular/cli@latest

and ensuring that the @angular/cli version in my package.json is fairly recent too.
Then I completely removed the node_modules folder and did a fresh install.

This works for me:

I downgraded my globally installed angular cli to 1.5.0.


npm remove -g @angular/cli
npm install -g @angular/cli@1.5.0

I think this only works if your project is running on Angular 4

More Issues: