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

Nx 17: Lerna packages dir cannot be used for generator dir #19795

Closed
1 of 4 tasks
jerkovicl opened this issue Oct 23, 2023 · 11 comments · Fixed by #19874
Closed
1 of 4 tasks

Nx 17: Lerna packages dir cannot be used for generator dir #19795

jerkovicl opened this issue Oct 23, 2023 · 11 comments · Fixed by #19874
Assignees

Comments

@jerkovicl
Copy link

jerkovicl commented Oct 23, 2023

Current Behavior

After upgrade to nx v17.0.1 angular library generator works with 'derived' option and not with 'as-provided' option, everything worked on v16.10

Expected Behavior

I want to generate angular library with 'as-provided' option

GitHub Repo

No response

Steps to Reproduce

image

Nx Report

nx report

 >  NX   Report complete - copy this into the issue template

   Node   : 18.18.0
   OS     : win32-x64
   npm    : 9.8.1

   nx (global)        : 17.0.1
   nx                 : 17.0.1
   @nx/js             : 17.0.1
   @nx/jest           : 17.0.1
   @nx/linter         : 17.0.1
   @nx/eslint         : 17.0.1
   @nx/workspace      : 17.0.1
   @nx/angular        : 17.0.1
   @nx/cypress        : 17.0.1
   @nx/devkit         : 17.0.1
   @nx/eslint-plugin  : 17.0.1
   @nx/plugin         : 17.0.1
   @nx/storybook      : 17.0.1
   @nrwl/tao          : 17.0.1
   @nx/web            : 17.0.1
   @nx/webpack        : 17.0.1
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @compodoc/compodoc : 1.1.22
   @storybook/angular : 7.5.1
   ngx-build-plus     : 16.0.0
   ---------------------------------------
   Local workspace plugins:
         @fiyu/lib-toolkit

Failure Logs

No response

Package Manager Version

No response

Operating System

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

Additional Information

No response

@mandarini
Copy link
Member

Hi there @jerkovicl ! Thanks for filing an issue! Unfortunately I could not reproduce. Here's my output:

npx nx generate @nx/angular:library --name=katerina --buildable=true --directory=libs/katerina --publishable=true --importPath=@katerina/katerina --projectNameAndRootFormat=as-provided

>  NX  Generating @nx/angular:library

CREATE libs/katerina/project.json
CREATE libs/katerina/README.md
CREATE libs/katerina/ng-package.json
CREATE libs/katerina/package.json
CREATE libs/katerina/tsconfig.json
CREATE libs/katerina/tsconfig.lib.json
CREATE libs/katerina/tsconfig.lib.prod.json
CREATE libs/katerina/src/index.ts
CREATE libs/katerina/src/lib/katerina.module.ts
CREATE libs/katerina/jest.config.ts
CREATE libs/katerina/src/test-setup.ts
CREATE libs/katerina/tsconfig.spec.json
CREATE libs/katerina/.eslintrc.json
UPDATE tsconfig.base.json

Can you please provide a simple reproduction repository and the exact command that failed for you?

@mandarini mandarini added scope: angular Issues related to Angular support in Nx blocked: repro needed labels Oct 23, 2023
@jerkovicl
Copy link
Author

jerkovicl commented Oct 24, 2023

@mandarini i run the same command as you nx g @nx/angular:library --name=jankec --buildable=true --publishable=true --importPath=@nas/jankec --directory=libs/jankec --projectNameAndRootFormat=as-provided --dry-run

image

if i change --projectNameAndRootFormat option to derived it works

image

@jerkovicl
Copy link
Author

@mandarini i have sent you a zip with repro on discord

@mandarini
Copy link
Member

@jerkovicl I cannot install the dependencies correctly there, can you please create a github repo instead? sorry about that :(

@jerkovicl
Copy link
Author

@mandarini hmm, sure but no need to installed them, just execute the generate lib command you will see. You can also just remove private libs from package.json and install will pass through.

@mandarini
Copy link
Member

@jerkovicl I need to install them, because if I don't install the dependencies I will not be able to run the command.. :/

@jerkovicl
Copy link
Author

@mandarini ok i understand, i thought you will run the command with npx as you did before

@mandarini
Copy link
Member

mandarini commented Oct 26, 2023

Here's the actual issue: https://github.com/mandarini/nx-lerna-17-bug

tl;dr:

When you have "packages": ["libs/*"] in your lerna.json you cannot use libs/ in the --directory option of generators, for example you cannot do nx g @nx/angular:lib katerina --directory=libs/katerina

This is a regression on Nx 17, it works on previous versions (eg. Nx 16.10)

@mandarini mandarini changed the title Angular library generator not working Nx 17: Lerna packages dir cannot be used for generator dir Oct 26, 2023
@mandarini mandarini added scope: misc Misc issues and removed blocked: repro needed scope: angular Issues related to Angular support in Nx labels Oct 26, 2023
@JamesHenry
Copy link
Collaborator

Thanks for the clear report @jerkovicl - we've diagnosed the issue on the nx core side and a fix will go up later today.

Please be aware that if you are using Nx 17 with lerna, you will still be pulling in nx 16 as well (because that's what lerna 7 depends on). If you're not seeing any issues then that's great, but something to be aware of.

We will be releasing lerna v8 soon which will depend on nx 17, it should be an easy migration

@jerkovicl
Copy link
Author

jerkovicl commented Oct 26, 2023

@JamesHenry that's good news!
@mandarini helped a lot with debugging and pinpointing the issue, so kudos to her aswell.
Yeah i didn't see any issues regarding publishing and versioning my libs so far.

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 Nov 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants