Unhelpful warning running ng g c with multiple projects sharing the same root
Bug Report or Feature Request (mark with an x)
- [X ] bug report
- [ ] feature request
Area
- [X ] devkit
- [ ] schematics
Versions
node: v8.11.3 npm: 6.1.0 ng cli: 6.1.0-rc.1
Repro steps
Create an angular.json with multiple projects. Set 1 as default project. Run ng g c
The log given by the failure
"Two or more projects are using identical roots. Unable to determine project using current working directory. Using default workspace project instead."
Desired functionality
This warning is extraneous when a default project is set and doesn't offer a solution to silence it. Instead of a warning it should just use the default project if one is set.
I had the same error message when running the command ng add @angular/pwa --project ng-zero
I then followed @ThuwarakeshM 's advice and had the "root": "e2e" in the angular.json file and it solved the issue.
I started getting this error after i added angular-playground. so i removed the entire "playground" section from angular.json.
the error is gone and the project seems to be working fine.
Just in case someone need it, I had the same problem here,
npm clean cache --force
rm -rf node_modules/
rm package-lock.json
npm install
those commands did the job!
Just in case someone need it, I had the same problem here,
npm clean cache --force rm -rf node_modules/ rm package-lock.json npm installthose commands did the job!
npm clean cache --force should be npm cache clean --force. You flipped the two 'c' commands.
I just got the same error; nodem_modules HAD been removed while upgrading the project.
It is a 'default' project with IBM's LoopBack, configured as a 'server' project, and a 'client' project that has Angular in it.
There is but one angular.json; it's inside .\client\angular.json
It DID put the component I was creating in the right place, namely src\app\app-routing.module.ts and updated the correct .\client\src\app\app.module.ts
I had tried this project before with Angular 'at the root' and a subdirectory called 'serverapi' with the LoopBack project in it, but that didn't seem to work as well, so I upgrade and restructured to the 'sample' configuration (per IBM).
Now I got this error, which seems weird as the angular.json is in the same directory I'm running the CLI in.
I had a BIG MESS of incompatible versions in this project, and tried to straightened everything out by upgrading everything. Here's the CLI -v:
Angular CLI: 7.2.2
Node: 10.7.0
OS: win32 x64
Angular: 7.2.2
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, http, language-service, material, platform-browser
... platform-browser-dynamic, platform-server, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.12.3
@angular-devkit/build-angular 0.12.3
@angular-devkit/build-optimizer 0.12.3
@angular-devkit/build-webpack 0.12.3
@angular-devkit/core 7.2.3
@angular-devkit/schematics 7.2.2
@ngtools/webpack 7.2.3
@schematics/angular 7.2.2
@schematics/update 0.12.2
rxjs 6.3.3
typescript 3.2.4
webpack 4.28.4
I have solved my problem by specifying the root property of my second project to e2e. That is I changed this:
"myproject-e2e": { "root": ""to:
"myproject-e2e": { "root": "e2e",This will bring up a new error when we try to create new components
More than one module matches. Use skip-import option to skip importing the component into the closest module. This can then be solved by specifying the module name in the cli
ng generate component comp_name --module=app.module
As suggested by @ThuwarakeshM, you can set a specific root for each project, however there is another fix which is to set the "defaultProject" at the root level of angular.json to the name of the main project. This means you aren't then required to change the root but it's probably best to configure both of these settings.
@mbrookson Adding a root value in the angular.json for my e2e project fixed it.
I got that error when tried to create a new component outside the app folder... I moved to the right folder and execute again... silly of me... (App\src\app)
Check the given link..
https://github.com/catalogicsoftware/ngx-dynamic-dashboard-framework/issues/21
Resolved.
@AlistairBates solution worked for me. Warning gone....
use <ng g c mycomponent --skip-import> it works fine
I was having this issue, after checking angular.json file, i found out there was no route defined
"root": ""
I changed it to
"root": "app"
where app was the name of the folder where i was having everything for the project, and it worked for me.
Hey, all I see lot of people are having issue with Two or more projects are using identical roots. Unable to determine project using current working directory. Using default workspace project instead. Two or more projects are using identical roots. Unable to determine project using current working directory. Using default workspace project instead. More than one module matches. Use skip-import option to skip importing the component into the closest module.
Please use this: while generating a component specify the module that u wanted to import in. ng g c nameOfTheComponent --module=nameOfTheModule
Thanks for reporting this issue. Luckily, it has already been fixed in one of the recent releases. Please update to the most recent version to resolve the problem.
If the problem persists in your application after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior. You can use ng new repro-app to create a new project where you reproduce the problem.
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.