When a workspace project has the same name as an npm dependency, the npm project conflicts with the workspace project.
Thus, cryptic errors occur such as:
> NX WARNING the following do not have configuration for "build"
- [object Object]
> NX No projects with "build" were run
Users are able to name a workspace project the same name as an npm dependency.
I have created a workspace using Angular CLI with two projects:
I run the following command:
npx nx run-many --target=build --projects=express
I expect that the project is built.
I get the following:
> NX WARNING the following do not have configuration for "build"
- [object Object]
> NX No projects with "build" were run
If I change the project name to express2, it works fine.
Please provide detailed steps for reproducing the issue.
npx create-nx-workspace nx-issuenpx ng add @nrwl/angular --unitTestRunner=jest --e2eTestRunner=cypressnpx ng g @nrwl/angular:application angular --routing --style=scss --skipTests --directory='' --e2eTestRunner=nonenpx ng add @nrwl/expressnpx ng g @nrwl/express:application express --frontendProject=angular --directory='' --unitTestRunner=nonePlease provide any relevant information about your setup:
@nrwl/angular : 8.12.0
@nrwl/cli : 8.12.0
@nrwl/cypress : 8.12.0
@nrwl/eslint-plugin-nx : Not Found
@nrwl/express : 8.12.0
@nrwl/jest : 8.12.0
@nrwl/linter : 8.12.0
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : 8.12.0
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 8.12.0
@nrwl/web : Not Found
@nrwl/workspace : 8.12.0
typescript : 3.5.3
As an addition, I believe, to this issue, running npx nx workspace-lint gives the following:
> NX ERROR The following file(s) do not belong to any projects:
- apps/express/src/environments/environment.prod.ts
- apps/express/src/environments/environment.ts
- apps/express/src/main.ts
- apps/express/tsconfig.app.json
- apps/express/tsconfig.json
Good catch, I'll take a look.
We ran into the same issue and the workaround of renaming the project works. We also discovered that this occurs when the project name is the same as one of the dependencies in package.json.
Sorry, I haven't had the chance yet to flush out a solution.
Here's what's going on and I updated the description as well.
The ProjectGraph has a map from project name to projects as nodes. Because there are different types of projects, projects with the same name but different types may override the other which causes unintended behavior.
Will try to flush out a solution as soon as I can.
Most helpful comment
Sorry, I haven't had the chance yet to flush out a solution.
Here's what's going on and I updated the description as well.
The
ProjectGraphhas a map from project name to projects as nodes. Because there are different types of projects, projects with the same name but different types may override the other which causes unintended behavior.Will try to flush out a solution as soon as I can.