Nx: Workspace project names can conflict with npm project names

Created on 29 Jan 2020  路  4Comments  路  Source: nrwl/nx

Current Behavior

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

Expected Behavior

Users are able to name a workspace project the same name as an npm dependency.

Original Description

Expected Behavior

I have created a workspace using Angular CLI with two projects:

  • one is named _angular_ and is an Angular project
  • one is named _express_ and is an epxress.js project

I run the following command:

npx nx run-many --target=build --projects=express

I expect that the project is built.

Current Behavior

I get the following:

>  NX   WARNING  the following do not have configuration for "build"

  - [object Object]


>  NX  No projects with "build" were run

Failure Information (for bugs)

If I change the project name to express2, it works fine.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. npx create-nx-workspace nx-issue
  2. npx ng add @nrwl/angular --unitTestRunner=jest --e2eTestRunner=cypress
  3. npx ng g @nrwl/angular:application angular --routing --style=scss --skipTests --directory='' --e2eTestRunner=none
  4. npx ng add @nrwl/express
  5. npx ng g @nrwl/express:application express --frontendProject=angular --directory='' --unitTestRunner=none

Context

Please 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
core bug

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 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.

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jon301 picture jon301  路  3Comments

vimalraj-a picture vimalraj-a  路  3Comments

about-code picture about-code  路  3Comments

elliotmendiola picture elliotmendiola  路  3Comments

markphip picture markphip  路  3Comments