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

[Bug] Unable to create new Spring Boot application with the latest version of NX #238

Open
Divaaaaaan opened this issue Oct 14, 2024 · 13 comments

Comments

@Divaaaaaan
Copy link

Plugin Name

@nxrocks/nx-spring-boot

Nx Report


 NX   Report complete - copy this into the issue template

Node           : 20.18.0
OS             : linux-x64
Native Target  : x86_64-linux
bun            : 1.1.30

nx             : 20.0.0
@nx/js         : 20.0.0
@nx/eslint     : 20.0.0
@nx/workspace  : 20.0.0
@nx/angular    : 20.0.0
@nx/devkit     : 20.0.0
@nx/vite       : 20.0.0
@nx/web        : 20.0.0
@nx/webpack    : 20.0.0
typescript     : 5.6.3
---------------------------------------
Community plugins:
@analogjs/content             : 1.8.2
@analogjs/platform            : 1.8.2
@analogjs/router              : 1.8.2
@analogjs/vite-plugin-angular : 1.8.2
@nxrocks/nx-spring-boot       : 10.2.6

### Expected Behaviour

Create a project using `nx g @nxrocks/nx-spring-boot:project`.

### Actual Behaviour

```~/Workspace/Work/Bedrock git:[main] bunx nx g @nxrocks/nx-spring-boot:project test --verbose

 NX  Generating @nxrocks/nx-spring-boot:project

✔ What kind of project are you generating? · application
✔ Which build system would you like to use? · maven-project
✔ Which packaging would you like to use? · jar
✔ Which version of Java would you like to use? · 22
✔ Which language would you like to use? · java
✔ What groupId would you like to use? · com.test
✔ What artifactId would you like to use? · test
✔ What package name would you like to use? · com.test.api

 NX   Cannot read properties of undefined (reading 'replace')

TypeError: Cannot read properties of undefined (reading 'replace')
    at removeWindowsDriveLetter (/home/user/Workspace/Work/Bedrock/node_modules/nx/src/utils/path.js:9:27)
    at normalizePath (/home/user/Workspace/Work/Bedrock/node_modules/nx/src/utils/path.js:16:12)
    at determineProjectNameAndRootOptions (/home/user/Workspace/Work/Bedrock/node_modules/@nx/devkit/src/generators/project-name-and-root-utils.js:10:58)
    at normalizeOptions (/home/user/Workspace/Work/Bedrock/node_modules/@nxrocks/nx-spring-boot/src/generators/project/lib/normalize-options.js:6:144)
    at projectGenerator (/home/user/Workspace/Work/Bedrock/node_modules/@nxrocks/nx-spring-boot/src/generators/project/generator.js:9:64)
    at /home/user/Workspace/Work/Bedrock/node_modules/nx/src/command-line/generate/generate.js:238:32
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async handleErrors (/home/user/Workspace/Work/Bedrock/node_modules/nx/src/utils/handle-errors.js:9:24)
    at async Object.handler (/home/user/Workspace/Work/Bedrock/node_modules/nx/src/command-line/generate/command-object.js:14:22)

### Steps to reproduce the behaviour

1. Create new nx workspace with "none" preset
2. Install @nxrocks/nx-spring-boot
3. Try and create a spring boot application
@Divaaaaaan
Copy link
Author

Divaaaaaan commented Oct 14, 2024

It seems like the options.directory value is null when logging out the options in normalize-options.js

@tinesoft
Copy link
Owner

Hi @Divaaaaaan

Thanks for reporting this, I'll have a look and provide an update soonish.

Stay tuned!

@Divaaaaaan
Copy link
Author

Hi @tinesoft

Cool no worries, did some investigating quick and it seems like the structure might have changed as the options for the generator doesn't seem to be passed through anymore. In the interim, I just updated that file to use options.name as the directory as well which is working but hope this helps make the checking on your side quicker and easier.

@Divaaaaaan
Copy link
Author

@tinesoft Just an update, seems like things are not playing well together when I edited the file 😅 so will wait for the update rather before continuing.

@WodenWang820118
Copy link

WodenWang820118 commented Oct 14, 2024

Having a look at the Nx plugin registry, it supports the Nx version between 16 and 18. When will the plugin be updated accordingly? Let me know if I can help upgrading.

@lordvins226
Copy link

lordvins226 commented Oct 28, 2024

Hi @Divaaaaaan.

"In Nx 20, generating projects will no longer derive the name and root"

So the correct way to create projects now is:
nx g @nxrocks/nx-spring-boot:project testapp --directory apps/testapp
This same change affects both Spring Boot and Flutter projects in Nx 20.
CleanShot 2024-10-28 at 4  18 22@2x

@Divaaaaaan
Copy link
Author

@lordvins226 Ah great, didn't see that in Nx 20. Thank you very much will have a look 👌

@crafael23
Copy link

Hi @Divaaaaaan.

"In Nx 20, generating projects will no longer derive the name and root"

So the correct way to create projects now is: nx g @nxrocks/nx-spring-boot:project testapp --directory apps/testapp This same change affects both Spring Boot and Flutter projects in Nx 20. CleanShot 2024-10-28 at 4  18 22@2x

I seem to have this exact same problem here, I do not seem to understand how to do the fix you suggested on my end.

image

@tinesoft
Copy link
Owner

Hi all

@crafael23 I'm actively updating all the create-nx-* packages for official support for Nx 20.
It should be released very soon.

I'll post back here when available.

@mostafamt
Copy link

@lordvins226 thank you very much, it works for me. you save my time.

@Hychin123
Copy link

Screenshot 2024-12-20 123551

i got the some problem and try to fix but it not work.

how to fix this problem ?

@Ossowitz
Copy link

lordvins226, hello! Thank you very much for providing a workaround! 💓

@lordvins226
Copy link

lordvins226 commented Dec 28, 2024

Screenshot 2024-12-20 123551

i got the some problem and try to fix but it not work.

how to fix this problem ?

@Hychin123 correct command: npx nx g @nxrocks/nx-spring-boot:project ecom-backend --directory apps/ecom-backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants