数ヶ月前のAngularのプロジェクトを触ろうとしたんですが、`ng generate` コマンドがエラーで動きませんでした。
“`
$ ng g service hoge
core_1.PriorityQueue is not a constructor
TypeError: core_1.PriorityQueue is not a constructor
at new TaskScheduler (/Users/yuhiisk/Desktop/test-app/node_modules/@angular-devkit/schematics/src/engine/task.js:20:23)
at SchematicEngine.createContext (/Users/yuhiisk/Desktop/test-app/node_modules/@angular-devkit/schematics/src/engine/engine.js:81:31)
at SchematicImpl.call (/Users/yuhiisk/Desktop/test-app/node_modules/@angular-devkit/schematics/src/engine/schematic.js:35:38)
at Promise (/Users/yuhiisk/Desktop/test-app/node_modules/@angular/cli/tasks/schematic-run.js:73:23)
at new Promise (
at Class.run (/Users/yuhiisk/Desktop/test-angular/test-app/node_modules/@angular/cli/tasks/schematic-run.js:72:16)
at Class.run (/Users/yuhiisk/Desktop/test-angular/test-app/node_modules/@angular/cli/commands/generate.js:161:33)
at resolve (/Users/yuhiisk/Desktop/test-app/node_modules/@angular/cli/ember-cli/lib/models/command.js:261:20)
at new Promise (
at Class.validateAndRun (/Users/yuhiisk/Desktop/test-angular/test-app/node_modules/@angular/cli/ember-cli/lib/models/command.js:240:12)
“`
解決策
どうやら `@angular-devkit/core` のモジュールが古いのが原因。
“`json
“devDependencies”: {
“@angular-devkit/core”: “OLD VERSION”,
…
}
“`
Latest版をインストールすることで解決します。
“`sh
$ npm i -D @angular-devkit/core@latest
“`
参考: Creating New Component throws error:PriorityQueue is not a constructor