vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
895 stars 56 forks source link

TS generator is not found if the app is a package in the monorepo #936

Open Lodin opened 1 year ago

Lodin commented 1 year ago

Description of the bug

In the Observability Kit I have a Hilla application installed as a single package in the monorepo to simplify JS-related development. The installation of node modules happens in the monorepo root, so there is no node_modules folder inside the package itself. However, the only path the application tries to find the TS generator is the node_modules in the same directory. Eventually, it just fails with the MODULE_NOT_FOUND error.

Minimal reproducible example

$ git clone git@github.com:vaadin/observability-kit.git
$ cd observability-kit
$ git checkout feat/hilla/telemetry
$ cd observability-kit-demo-hilla
$ mvn spring-boot:run -Pobserve

Expected behavior

Application runs without any problem

Actual behavior

Application fails with the following error:

Error: Cannot find module '<path>\observability-kit\observability-kit-demo-hilla\node_modules\@hilla\generator-typescript-cli\bin\index.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Versions:

- Vaadin / Hilla version: `24.1.0-alpha5`
- Node version: `v18.15.0`
- Java version: 17
- OS version: Windows 11
platosha commented 1 year ago

We could either resolve in node_modules of ancestor directories, or use npm exec --no to use Node resolve logic.