0

I have a custom Angular schematic (on an internal repo and NPM feed) that does not generate a new workspace and application when invoked from the command line. I attached a GIF that shows both the missing behavior when I run the custom schematic i.e., no file tree with CREATE commands, as well as the behavior when I attempt to execute a custom schematic collection that doesn't exist.

It looks like the custom schematic name is valid, but there's some other unobserved error. Has anyone encountered this behavior before or have some suggestions about how I might go about debugging the issue?

enter image description here

ericksoen
  • 821
  • 8
  • 14

2 Answers2

0

For debugging you can follow the directions on Node's debugging guide and use the tool of your choice. I personally prefer Chrome Inspector so run node --inspect-brk ng serve for instance from the console and open Chrome.

kenny87
  • 29
  • 4
0

The root cause of my issue seems to have been a very mangled NPM installation that was eventually resolved by uninstalling NPM, Node, and NVM (Node Version Manager), deleting any NPM caches, and finally reinstalling only NVM. The net effect of this was a consistent, stable global install of the Angular CLI on my workstation.

I had been able to debug my Jasmine tests in VS Code to see that the application was generated with the right structure and assets, so here's some updated information on debugging schematics in VS Code (I had to modify the instructions slightly from the Angular CLI ReadMe to work for schematics.

launch.json { "type": "node", "request": "launch", "name": "Schematics debugger", "program": "${workspaceFolder}/node_modules/@angular-devkit/schematics-cli/bin/schematics.js", "args": [ ".:ng-new", "--name=imo-default" ], "outFiles": [ "${workspaceFolder/**/*.js}" ], "preLaunchTask": "npm:run:build" }

task.json { "identifier": "npm:run:build", "type": "npm", "script": "build", "problemMatcher": [] }

Full VS code debug files available in my Schematic-Demo GitHub repo.

ericksoen
  • 821
  • 8
  • 14