Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Library schematic does not support path property

Offen
#16,080 6 Kommentare 9 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
angular, typescript
Bereich
cli

Rechercherichtung

Beginne mit dem im Issue verlinkten Repository zur minimalen Reproduktion und verfolge den Einstiegspunkt des Library-Schematics unter @schematics/angular/library/index.js sowie utility/workspace.js aus dem Fehler-Stack. Bestätige, wie der Pfad behandelt wird, wenn die Anwendung in einem Unterordner generiert wird. Als erledigt gilt die Aufgabe, wenn das Library-Schematic den Pfad akzeptiert und die angular.json der generierten Anwendung ohne den Workspace-Fehler findet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

area: @schematics/angular feature feature: insufficient votes

🐞 Bug report

Command (mark with an x)
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
- [X] schematics
Is this a regression?

Not as far as I know

Description

I tried to create a schematic that generates an application and adds a library to it. However, the library schematic does not accept a path as parameter and it then attempts to create the library in the folder that contains the application. Specifically, it tries to read the angular.json file from the folder containing the application folder (e.g. the folder where the schematic is run).

Note that I expected the path property to work, as it's included with most of the other Angular schematics, for example component, module and service.

🔬 Minimal Reproduction

A minimal reproduction may be found in this repo.

It also addresses a problem I had when trying to work around this with applyToSubtree.

Here is the simplest description I could come up with.

Given this factory:

export function createProject(_options: any): Rule {
  return (_tree: Tree, _context: SchematicContext) => {
    return chain([
      externalSchematic('@schematics/angular', 'ng-new', optionsNew),
      externalSchematic('@schematics/angular', 'library', optionsLib)
    ]);
  };
}

If you execute the schematic in a folder named /parent/folder and the app generates in a new folder named app (/parent/folder/app), the library schematic searches for the angular.json in /parent/folder instead of /parent/folder/app.

🔥 Exception or Error

An error occured:
Error: Unable to locate a workspace file for workspace path.
    at Object.readWorkspace (C:\dev\scratchpad\scaffolding-tests\node_modules\@angular-devkit\core\src\workspace\core.js:74:19)
    at async Object.getWorkspace (C:\dev\scratchpad\scaffolding-tests\node_modules\@schematics\angular\utility\workspace.js:51:27)
    at async C:\dev\scratchpad\scaffolding-tests\node_modules\@schematics\angular\library\index.js:153:27

🌍 Your Environment


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 8.3.1
Node: 12.12.0
OS: win32 x64
Angular: undefined
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.803.1 (cli-only)
@angular-devkit/core         8.3.17
@angular-devkit/schematics   8.3.17
@schematics/angular          8.3.1 (cli-only)
@schematics/update           0.803.1 (cli-only)
rxjs                         6.4.0
typescript                   3.5.3

Similar issues

https://github.com/angular/angular-cli/issues/17598

Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
17 Std. 25 Min.
Gemergte PRs (30 T.)
183

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus angular/angular-cli

Alle Issues in angular/angular-cli

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.