简体   繁体   中英

Schematic "library" not found in collection "@schematics/angular"

I'm getting the following error when trying to create a library in angular cli

Schematic "library" not found in collection "@schematics/angular".
Error: Schematic "library" not found in collection
"@schematics/angular".
    at SchematicEngine.createSchematic (/home/rafaelvicio/node-v8.9.3-linux-x64/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/src/engine/engine.js:143:23)
    at CollectionImpl.createSchematic (/home/rafaelvicio/node-v8.9.3-linux-x64/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/src/engine/collection.js:12:29)
    at Object.getSchematic (/home/rafaelvicio/node-v8.9.3-linux-x64/lib/node_modules/@angular/cli/utilities/schematics.js:47:23)
    at Class.run (/home/rafaelvicio/node-v8.9.3-linux-x64/lib/node_modules/@angular/cli/tasks/schematic-get-options.js:12:40)
    at Class.beforeRun (/home/rafaelvicio/node-v8.9.3-linux-x64/lib/node_modules/@angular/cli/commands/generate.js:101:31)
    at Promise.resolve.then (/home/rafaelvicio/node-v8.9.3-linux-x64/lib/node_modules/@angular/cli/ember-cli/lib/cli/cli.js:138:24)
    at <anonymous>

Command ng --version

shows this

Angular CLI: 1.7.4
Node: 8.9.3
OS: linux x64
Angular: 


node -v
v8.9.3

npm -v
5.5.1
npm i -g @schematics/angular 

updates you to the latest version of the schematic. Also important to update your angular cli:

npm i -g @angular/cli

Library support starts from Angular cli version 6 & above...

Please Check the release note for more information...

这对我有用:

npm i @schematics/angular

I got this error when I tried to generate a service myService :

ng generate myService

This fixed the problem:

ng generate service myService

Why can't someone make a UNIX shell that does what I want, not what I type? :-)

ng config cli.defaultCollection @ngrx/schematics

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM