analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.61k stars 251 forks source link

Trying to add AnalogJS to an existing Nx monorepo does not work #1265

Closed bjornharvold closed 3 months ago

bjornharvold commented 3 months ago

Please provide the environment you discovered this bug in.

Node           : 22.5.1
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.8.2

nx (global)        : 19.5.7
nx                 : 19.5.7
@nx/js             : 19.5.7
@nx/jest           : 19.5.7
@nx/linter         : 19.5.7
@nx/eslint         : 19.5.7
@nx/workspace      : 19.5.7
@nx/angular        : 19.5.7
@nx/cypress        : 19.5.7
@nx/devkit         : 19.5.7
@nx/eslint-plugin  : 19.5.7
@nx/storybook      : 19.5.7
@nrwl/tao          : 19.5.7
@nx/web            : 19.5.7
@nx/webpack        : 19.5.7
typescript         : 5.5.4
---------------------------------------
Community plugins:
@compodoc/compodoc               : 1.1.25
@fortawesome/angular-fontawesome : 0.15.0
@jsverse/transloco               : 7.4.3
@ng-bootstrap/ng-bootstrap       : 17.0.0
@ngrx/component                  : 18.0.2
@ngrx/component-store            : 18.0.2
@ngrx/data                       : 18.0.2
@ngrx/effects                    : 18.0.2
@ngrx/entity                     : 18.0.2
@ngrx/router-store               : 18.0.2
@ngrx/schematics                 : 18.0.2
@ngrx/store                      : 18.0.2
@ngrx/store-devtools             : 18.0.2
@storybook/angular               : 8.2.8
angular-calendar                 : 0.31.1

Which area/package is the issue in?

platform

Description

Hi Brandon + Team πŸ¦ΈπŸΎβ€β™‚οΈ

We have a Nx monorepo with a standard project layout:

root

Please provide the exception or error you saw

We followed the instructions on using an existing Nx repo and executed the below commands in project root:

`npm install @analogjs/platform --save-dev`

followed by

`npx nx g @analogjs/platform:app docs`

The response we got was:

 NX  Generating @analogjs/platform:app

βœ” Add TailwindCSS for styling? (y/N) Β· false
βœ” Add tRPC for typesafe client/server interaction? (y/N) Β· false

 NX   Nx must be installed to execute this plugin


### Other information

_No response_

### I would be willing to submit a PR to fix this issue

- [ ] Yes
- [X] No
brandonroberts commented 3 months ago

Thanks @bjornharvold, I'm unable to reproduce this issue.

Here's my log

nvm install 22.5.1
Downloading and installing node v22.5.1...
Downloading https://nodejs.org/dist/v22.5.1/node-v22.5.1-darwin-arm64.tar.xz...
######################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v22.5.1 (npm v10.8.2)
$npx create-nx-workspace@latest nx-1957-analog
Need to install the following packages:
create-nx-workspace@19.5.7
Ok to proceed? (y) 

 NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

βœ” Which stack do you want to use? Β· angular
βœ” Integrated monorepo, or standalone project? Β· integrated
βœ” Application name Β· my-app
βœ” Which bundler would you like to use? Β· esbuild
βœ” Default stylesheet format Β· css
βœ” Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? Β· No

βœ” Test runner to use for end to end (E2E) tests Β· playwright
βœ” Which CI provider would you like to use? Β· skip
βœ” Would you like remote caching to make your build faster? Β· skip

 NX   Creating your v19.5.7 workspace.

βœ” Installing dependencies with npm
βœ” Successfully created the workspace: nx-1957-analog.

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

 NX   First time using Nx? Check out this interactive Nx tutorial.

https://nx.dev/angular-tutorial/1-code-generation

$cd nx-1957-analog 
$npm i @analogjs/platform --save-dev
npm warn deprecated npmlog@5.0.1: This package is no longer supported.
npm warn deprecated are-we-there-yet@2.0.0: This package is no longer supported.
npm warn deprecated glob@8.1.0: Glob versions prior to v9 are no longer supported
npm warn deprecated gauge@3.0.2: This package is no longer supported.

added 282 packages, removed 14 packages, changed 8 packages, and audited 1784 packages in 33s

257 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
$nx g @analogjs/platform:app docs

 NX  Generating @analogjs/platform:app

βœ” Add TailwindCSS for styling? (y/N) Β· false
βœ” Add tRPC for typesafe client/server interaction? (y/N) Β· false
UPDATE package.json
CREATE apps/docs/project.json
CREATE apps/docs/.eslintrc.json
CREATE apps/docs/index.html
CREATE apps/docs/package.json
CREATE apps/docs/public/.gitkeep
CREATE apps/docs/public/analog.svg
CREATE apps/docs/public/favicon.ico
CREATE apps/docs/src/app/app.component.spec.ts
CREATE apps/docs/src/app/app.component.ts
CREATE apps/docs/src/app/app.config.server.ts
CREATE apps/docs/src/app/app.config.ts
CREATE apps/docs/src/main.server.ts
CREATE apps/docs/src/main.ts
CREATE apps/docs/src/server/routes/v1/hello.ts
CREATE apps/docs/src/styles.css
CREATE apps/docs/src/test-setup.ts
CREATE apps/docs/src/vite-env.d.ts
CREATE apps/docs/tsconfig.app.json
CREATE apps/docs/tsconfig.editor.json
CREATE apps/docs/tsconfig.json
CREATE apps/docs/tsconfig.spec.json
CREATE apps/docs/vite.config.ts
CREATE apps/docs/src/app/pages/(home).page.ts
CREATE apps/docs/src/app/pages/analog-welcome.component.ts

added 116 packages, removed 3 packages, changed 6 packages, and audited 1897 packages in 6s

285 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Does it work for you with a new workspace?

bjornharvold commented 3 months ago

Hi @brandonroberts

It broke right here:

if (!nxVersion) {
        throw new Error((0, devkit_1.stripIndents) `Nx must be installed to execute this plugin`);
    }

Older versions of Nx does not install the "nx" dev dependency by default which your library is expecting.

Added it and projects generates as expected.

Cheers, Bjorn