Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bypass nx generate @nx/angular:library "You can't specify both a directory and a name with a directory path" #20756

Closed
1 of 4 tasks
urielzen opened this issue Dec 14, 2023 · 2 comments · Fixed by #20768
Closed
1 of 4 tasks
Assignees

Comments

@urielzen
Copy link

Current Behavior

I am trying to create an Angular library named service/auth in directory libs/service/auth.

image

This gives me the following error

You can't specify both a directory (libs/service/auth) and a name with a
directory path (service/auth).
Please specify either a directory or a name with a directory path.

image

I then change the name of the library to service-auth as well as the directory to libs/service-auth. And that works with no problem.

image

But then I can bypass the initial validation error above by moving the newly created library. Using both the directory and name that I wanted originally. And I get no errors.

image

image

I end up with this in the tsconfig.base.json

"@lf/service/auth": ["libs/service/auth/src/index.ts"],

Expected Behavior

I would expect the validation error to be consistent between creating a library and moving it.

GitHub Repo

No response

Steps to Reproduce

See above

Nx Report

Node   : 18.17.1
   OS     : win32-x64
   npm    : 8.11.0
   
   nx (global)        : 17.1.3
   nx                 : 17.2.0
   @nx/js             : 17.2.0
   @nx/jest           : 17.2.0
   @nx/linter         : 17.2.0
   @nx/eslint         : 17.2.0
   @nx/workspace      : 17.2.0
   @nx/angular        : 17.2.0
   @nx/cypress        : 17.2.0
   @nx/devkit         : 17.2.0
   @nx/eslint-plugin  : 17.2.0
   @nrwl/tao          : 17.2.0
   @nx/web            : 17.2.0
   @nx/webpack        : 17.2.0
   typescript         : 5.2.2
   ---------------------------------------
   Community plugins:
   @fortawesome/angular-fontawesome : 0.14.0
   @ngrx/component-store            : 17.0.1
   @ngrx/signals                    : 17.0.1

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@urielzen urielzen changed the title Bypass nx generate @nx/angular:library " Bypass nx generate @nx/angular:library "You can't specify both a directory and a name with a directory path" Dec 14, 2023
@Coly010 Coly010 added the scope: angular Issues related to Angular support in Nx label Dec 14, 2023
@leosvelperez leosvelperez added scope: misc Misc issues and removed scope: angular Issues related to Angular support in Nx labels Dec 14, 2023
@leosvelperez leosvelperez self-assigned this Dec 14, 2023
@leosvelperez
Copy link
Member

Thanks for reporting this!

Please note that a name of service/auth won't be allowed for the logical name of a project. Path segments are only allowed if you have scoped package names (e.g. @acme/my-project-name). When providing a path in the name (like service/auth), Nx project generators treat it as the directory and use the last segment (or anything after a @) as the project name. That's why you can't provide both a directory and a project name containing path segments.

As you pointed out, there's a bug in the move generator that's allowing that, which it's not consistent with the project generation. In the case of the move generator, the --newProjectName option won't allow providing path segments (unless it's a scoped package name) because the destination is a required option and will already contain the directory.

I'll push a fix for that.

Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants