nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
22.69k stars 2.27k forks source link

19.2.0 update broke many generators (including @nx/next) #26470

Open Fabb111 opened 1 month ago

Fabb111 commented 1 month ago

Current Behavior

I tried generating a new application in a completely fresh, empty NX workspace and all generators (including @nx/next) I tried out failed with the error The "path" argument must be of type string. Received undefined.

Example: nx g @nx/next:app sample-name.

After checking the stacktrace I narrowed it down, in both cases, to the jest plugin (@nx/jest) even though the other generator is not even using it. It tries reading projectGraphCacheDirectory which was removed in this PR https://github.com/nrwl/nx/pull/23381 / commit https://github.com/nrwl/nx/commit/5e39cb00194f01a17c007c101452e47a91b547db released with 19.2.0. The "fix" is probably to not make a breaking change in a minor version bump and re-add projectGraphCacheDirectory that just exactly exports the same thing as workspaceDataDirectory, since this not only breaks generators/plugins in control of nx like the jest plugin, but also potentially all other generators reading the projectGraphCacheDirectory.

Expected Behavior

Re-add projectGraphCacheDirectory and probably update the jest plugin to use the new export name so nx can be used again as intended.

GitHub Repo

No response

Steps to Reproduce

  1. Create a new NX workspace
  2. nx g @nx/next:app sample-name
  3. Fail

Nx Report

Node   : 21.5.0
OS     : darwin-x64
pnpm   : 9.0.1

nx (global)    : 19.0.4
nx             : 19.2.2
@nx/js         : 19.2.2
@nx/eslint     : 19.2.2
@nx/workspace  : 19.2.2
@nx/next       : 19.2.2
@nrwl/tao      : 19.0.4
---------------------------------------
Registered Plugins:
@nx/next/plugin

Failure Logs

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at join (node:path:1175:7)
    at Object.<anonymous> (---/node_modules/.pnpm/@nx+jest@19.0.4_@babel+traverse@7.24.7_@types+node@20.14.2_babel-plugin-macros@2.8.0_nx@19.0._3e5r4kz65llpobkwiktchibtuu/node_modules/@nx/jest/src/plugins/plugin.js:15:35)
    at Module._compile (node:internal/modules/cjs/loader:1375:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1434:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Module.require (node:internal/modules/cjs/loader:1234:19)
    at Mod.require (---/node_modules/.pnpm/nx@19.2.2/node_modules/nx/bin/init-local.js:154:36)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (---/node_modules/.pnpm/@nx+jest@19.0.4_@babel+traverse@7.24.7_@types+node@20.14.2_babel-plugin-macros@2.8.0_nx@19.0._3e5r4kz65llpobkwiktchibtuu/node_modules/@nx/jest/src/generators/init/init.js:5:18)

Package Manager Version

No response

Operating System

Additional Information

No response

ffMathy commented 3 weeks ago

@ndcunningham @FrozenPandaz any progress on this? Generators can't be used in NX anymore, which I'd say is quite critical. Is it being worked on?

ffMathy commented 3 weeks ago

Also, this shouldn't be just scope: nextjs. It happens for Node as well, and various other generators.

JakeGinnivan commented 2 weeks ago

This broke an internal plugin which started using the project crystal stuff as the code examples showed using projectGraphCacheDirectory to cache the results.

gitLinda commented 2 weeks ago

Hi I am using nx version 18.3.3 and have some custom generators. Some of them are using the nx react generators and add few things on top. Currently I get the same error as described here in this issue. When I run with verbose I get:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:405:5)
    at validateString (node:internal/validators:162:11)
    at join (node:path:429:7)
    at Object.<anonymous> (C:\Users\lkrue\AppData\Local\Temp\tmp-35980-mLe4OtkhkdUF\node_modules\.pnpm\@nx+vite@18.3.3_@types+node@20.14.9_nx@19.3.2_typescript@5.5.2_vite@5.3.2_vitest@1.6.0\node_modules\@nx\vite\src\plugins\plugin.js:24:34)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at Mod.require (C:\Users\lkrue\develop\projects\BJB\itdev-348-latest-4\node_modules\.pnpm\nx@18.3.3\node_modules\nx\bin\init-local.js:157:36)

When the user chooses vite as bundler, nx seems to bring in stuff from 19.3.2 (latest) which causes the error. See this line from the error above: at Object.<anonymous> (C:\Users\lkrue\AppData\Local\Temp\tmp-35980-mLe4OtkhkdUF\node_modules\.pnpm\@nx+vite@18.3.3_@types+node@20.14.9_nx@19.3.2_typescript@5.5.2_vite@5.3.2_vitest@1.6.0\node_modules\@nx\vite\src\plugins\plugin.js:24:34) If I put an explicit dependency to @nx/vite 18.3.3 in the package.json before running my generator it uses the correct version and works fine.