You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ng g component <ComponentName> Failed with error "Project "undefined" does not exist." #23848
Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
After updated to angular14, the defaultProjectproperty in angular.json was removed after run ng update, however, when i
try to create an component with ng g component command, it failed with "Project "undefined" does not exist." error, if i add defaultProject back to angular.json, the command will success, but a warning appeared in the console output "DEPRECATED: The 'defaultProject' workspace option has been deprecated. The project to use will be determined from the current working directory."
The root problem here is that a project cannot be determined. You can either change the current working directory using (cd) or provide the name of the project using the --project option.
We should update the error message to be more actionable.
This error occurs even when i executed ng g component in the root directory of the project. I have no idea how the cli determine the current project, but i don't think is only things about the error message
The problem here is that your projects are misconfigured in the angular.json. You have two projects in the same directory as the root is configured the same, as such the CLI cannot determine which project you intend to use.
Activity
alan-agius4 commentedon Sep 2, 2022
The root problem here is that a project cannot be determined. You can either change the current working directory using (cd) or provide the name of the project using the
--projectoption.We should update the error message to be more actionable.
laggage commentedon Sep 2, 2022
@alan-agius4
This error occurs even when i executed
ng g componentin the root directory of the project. I have no idea how the cli determine the current project, but i don't think is only things about the error messagealan-agius4 commentedon Sep 2, 2022
Can you please share you
angular.json? You can option thearchitectsections if you'd like.fix(@schematics/angular): mark project as required option
laggage commentedon Sep 2, 2022
@alan-agius4 You can see my angular.json below
angular.json
{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "blog-admin": { "projectType": "application", "root": "", "sourceRoot": "src", "architect": {...}, }, "blog-admin-e2e": { "root": "", "sourceRoot": "", "projectType": "application", "architect": { "e2e": { "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "./protractor.conf.js", "devServerTarget": "blog-admin:serve" }, "configurations": { "ci": { "protractorConfig": "./protractor.ci.conf.js" } } }, "lint": { "builder": "@angular-eslint/builder:lint", "options": { "lintFilePatterns": ["e2e/**/*.ts"] } } } } }, "schematics": { "@schematics/angular:component": { "prefix": "cnb", "style": "less" }, "@schematics/angular:directive": { "prefix": "cnb" } } }alan-agius4 commentedon Sep 2, 2022
The problem here is that your projects are misconfigured in the
angular.json. You have two projects in the same directory as therootis configured the same, as such the CLI cannot determine which project you intend to use.laggage commentedon Sep 2, 2022
After I changed
blog-admin-e2e.roottoe2e, things worked, thanks for helpfix(@schematics/angular): mark project as required option
angular-automatic-lock-bot commentedon Oct 3, 2022
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.