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 am receiving below warning and error when running ng add @angular/pwa --project TestProject
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.
newTree.optimize is not a function
Same warning when doing ng g c testComponent
I got the same warning when I have only one project (well a second, the default -e2e project). And it appears even after adding the --project flag
cyphercodes@Cypher:~/WebstormProjects/ccdesk-ng$ ng g c src/app/administration/ import-export --module app.module.ts Two or more projects are using identical roots. Unable to determine project using current working directory. Using default workspace project instead. Selector (app-) is invalid.
@HussamSC Updating CLI to 6.1.2 and Angular from 6.0.9 to 6.1.0 isn't fixed this issue for me
I just downloaded SSR Example from https://angular.io/guide/universal#universal-template-engine
and i just typed 'ng g c [componentName]', then terminal says 'Two or more projects are using identical roots. Unable to determine project using current working directory.'
So i updated CLI and Angular version which i mentioned above but it's not fixed
@HussamSC That did not help for me still getting the warning
@CodySchrank what is your @angular-devkit/build-angular? I have stopped getting the warning.
I have the exact same issue Here is my angular.json
{
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"myproject": {
"root": "",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/browser",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
{
"glob": "**/*",
"input": "src/assets",
"output": "/assets"
},
{
"glob": "favicon.ico",
"input": "src",
"output": "/"
}
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "myproject:build"
},
"configurations": {
"production": {
"browserTarget": "myproject:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "myproject:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [],
"styles": [
"src/styles.css"
],
"assets": [
{
"glob": "**/*",
"input": "src/assets",
"output": "/assets"
},
{
"glob": "favicon.ico",
"input": "src",
"output": "/"
}
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json"
}
}
}
},
"myproject-e2e": {
"root": "",
"projectType": "application",
"cli": {},
"schematics": {},
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "myproject:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"cli": {},
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "css"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}
When I type
$ ng g c home
Two or more projects are using identical roots. Unable to determine project using current working directory. Using default workspace project instead.
Option (project) is required.
having the same problem here, below are the versions of devkit i have installed. Note that i'm on cli 6.1.1 because of a compiler-cli bug
@angular-devkit/architect 0.7.4
@angular-devkit/build-angular 0.7.4
@angular-devkit/build-optimizer 0.7.4
@angular-devkit/build-webpack 0.7.4
@angular-devkit/core 0.7.4
@angular-devkit/schematics 0.7.4
@angular/cdk 6.4.5
@angular/cli 6.1.1
@angular/compiler 6.1.1
@angular/compiler-cli 6.1.1
@angular/flex-layout 6.0.0-beta.17
@angular/material 6.4.5
@ngtools/webpack 6.1.4
@schematics/angular 0.7.3
@schematics/update 0.7.3
Have you tried specifying the project and ~~app~~ module name? I had similar issue and had to use ng generate component apply --project <project-name> --module <probably-"app"-but-check-your-module-name> ~~do~~ due to updates to Angular CLI
Hope this helps!
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
I am seeing this as well. Tried update everything.
Angular CLI: 6.1.4
Node: 10.1.0
OS: darwin x64
Angular: 6.1.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.7.4
@angular-devkit/build-angular 0.7.4
@angular-devkit/build-optimizer 0.7.4
@angular-devkit/build-webpack 0.7.4
@angular-devkit/core 0.7.4
@angular-devkit/schematics 0.7.4
@angular/cli 6.1.4
@ngtools/webpack 6.1.4
@schematics/angular 0.7.4
@schematics/update 0.7.4
rxjs 6.2.2
typescript 2.9.2
webpack 4.9.2
Run a command in my /src/app/client folder:
ng g c -s /demo/hamburger/hamburger-push --spec=false --module demo -d
I get the same error as everyone else:
Two or more projects are using identical roots. Unable to determine project using current working directory. Using default workspace project instead.
This is the same project I've been using for months, never saw this message before.
I'm getting the same error message. I'm new to Angular, so cannot tell if/what I should be doing differently.
I have the same error, if there is more the one module in your file structure? Need to add the folder path when adding components. app.module.ts home.module.ts shared.module.ts To add new component specify the module you want to use.
ng g c home/about-us This generates a new component within the home folder using the homemodule.ts
@alvics See my comment, I have multiple modules:
/app.module.ts
/demo/demo.module.ts
/web/web.module.ts
So, I want to add a component to the demo module, in a folder called "hamburger", inside the demo folder along with all the other demos. So I use:
ng g c -s ng g c -s /demo/hamburger/hamburger-push --spec=false --module demo -d --spec=false --module demo -d
This correctly gives me
/demo/hamburger/hamburger-push/hamburger-push.component.ts
/demo/hamburger/hamburger-push/hamburger-push.component.html
and adds this component to my /demo/demo.module.ts
I don't see why the error is shown, this did not happen with the previous version of angular cli.
Same issue here when attempting to generate module (ng g m)
Downgrading @angular/cli from version 6.1.5 to 6.0.8 solved problem.
For me this was caused by the e2e project having the same value for it's "root" attribute as the main project (both were "").
I changed the e2e project "root" attribute to something else in angular.json and it worked.
I upgraded from Angular 5 to Angular 6. Maybe there was a problem in the upgrade process.
@ThuwarakeshM Thanks. this is work for me -
"myproject-e2e": {
"root": "e2e",
@ThuwarakeshM Thanks. your solution worked for me.
For me, I basically copied/forked a repo (already had that other repo in my directory), and I didn't update the angular.json to have new values for the "projects": {"duplicate-project-name" : {"root":""}}. Thought i'd share since the error message threw me off as well.