I've created a few schematics before, before Angular 6.0. The same steps I did in Angular 5.x now always leads to the error schematic 'my-schematic' not found in collection @schematics/angular
when I try to generate some code on a hosting application (of Angular 6)?.
My setup (global Angular stuff):
Angular CLI: 6.0.0
Node: 8.11.1
OS: win32 x64
@angular-devkit/{architect, core, schematics} 0.6.0
@schematics/angular 0.6.0
rxjs 6.1.0
typescript 2.7.2
My steps:
- Ran
schematics schematic --name=my-first-schematics
. So it creates a new schematics project with three sample schemas in it. Then I navigated into that new foldercd my-first-schematics
. - Ran
npm run build
. It built without errors. - Ran
schematics .:my-first-schematics
. Result: Error"my-first-schematics" not found in collection "."
I saw in some blogs that they performed this step without problems, though. I never used to run this command, and I'm not sure what it actually does, so I'll proceed assuming that this command isn't necessary after all. - Ran
npm link
so that I can use this new schematics collection in a new project. - In another prompt window, I created a new application:
ng new schematics-consumer
, then after the npm installs,cd schematics-consumer
. - Ran
npm link my-first-schematics
so I now have access to that schematics library. - I navigated to
src/app
as that's where I want to generate my file. - Ran
ng g my-schematic -c my-first-schematics
. Resulted in errorSchematic "my-schematic" not found in collection "@schematics/angular"
. I specified a collection. Why is it not seeing my new collection, and it's still thinking that every schematic is in@schematics/angular
?
So, I cannot generate anything with schematics. I did not modify anything in the default code generated by schematics schematic name=my-first-schematics
.
Is there a new set of commands, procedures, etc. to create our own custom schematics? What steps am I missing? What else do I need to install? I'll provide more information if necessary.
At this time, there are no new guides or blogs on schematics, as 6.0 is only a few weeks old, so I'm assuming the old way should still work.