{"record":{"id":"a83d159df9e78390","repo":"angular/components","slug":"angular-material-has-been-set-up-in-your-workspace","errorCode":null,"errorMessage":"Angular Material has been set up in your workspace. There is no additional setup required for consuming Angular Material in your library project.\\n\\nIf you intended to run the schematic on a different project, pass the `--project` option.","messagePattern":"Angular Material has been set up in your workspace\\. There is no additional setup required for consuming Angular Material in your library project\\.\\\\n\\\\nIf you intended to run the schematic on a different project, pass the `--project` option\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/material/schematics/ng-add/setup-project.ts","lineNumber":30,"sourceCode":"import {ProjectType} from '@schematics/angular/utility/workspace-models';\nimport {addFontsToIndex} from './fonts/material-fonts';\nimport {Schema} from './schema';\nimport {addThemeToAppStyles} from './theming/theming';\n\n/**\n * Scaffolds the basics of a Angular Material application, this includes:\n *  - Add Packages to package.json\n *  - Adds pre-built themes to styles.ext\n */\nexport default function (options: Schema): Rule {\n  return async (host: Tree, context: SchematicContext) => {\n    const workspace = await readWorkspace(host);\n    const project = getProjectFromWorkspace(workspace, options.project);\n\n    if (project.extensions['projectType'] === ProjectType.Application) {\n      return chain([addThemeToAppStyles(options), addFontsToIndex(options)]);\n    }\n    context.logger.warn(\n      'Angular Material has been set up in your workspace. There is no additional setup ' +\n        'required for consuming Angular Material in your library project.\\n\\n' +\n        'If you intended to run the schematic on a different project, pass the `--project` ' +\n        'option.',\n    );\n    return;\n  };\n}\n","sourceCodeStart":12,"sourceCodeEnd":39,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material/schematics/ng-add/setup-project.ts#L12-L39","documentation":"The `ng-add` project setup schematic (`setupProject`) configures theming and fonts only for application projects. When the target project's `projectType` is `library`, there is nothing to set up, so it logs this warning and returns without scheduling any rules. Angular Material is already consumable from any library in the workspace once installed.","triggerScenarios":"Running `ng add @angular/material` (or `ng generate @angular/material:ng-add --project=<lib>`) with `--project` pointing at a library-type project in angular.json.","commonSituations":"Monorepos where the default project is a library, or developers explicitly passing a library project name intending to 'set up' Material inside the library.","solutions":["Re-run with an application project: `ng add @angular/material --project=my-app`.","If the intent was to use Material in a library, just add `@angular/material` to the library's dependencies — no extra setup is needed.","Set the workspace default project to an application if `ng add` keeps resolving the library."],"exampleFix":"// before\nng add @angular/material --project=my-lib\n\n// after\nng add @angular/material --project=my-app","handlingStrategy":"validation","validationCode":"const ws = require('./angular.json');\nconst project = ws.projects[options.project];\nif (project?.projectType !== 'application') {\n  console.warn(`${options.project} is a library; ng-add setup is a no-op.`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the --project target's projectType in angular.json before ng add.","Remember Material needs no per-library setup; add it to dependencies instead.","Set a defaultProject that is an application in monorepos."],"tags":["angular","material","schematics","ng-add","library-project"],"backgroundTag":"ng-add-library-project-noop","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}