nx
nx copied to clipboard
19.2.0 update broke many generators (including @nx/next)
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
- Create a new NX workspace
nx g @nx/next:app sample-name- 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/@[email protected]_@[email protected]_@[email protected][email protected][email protected]._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/[email protected]/node_modules/nx/bin/init-local.js:154:36)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (---/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected]._3e5r4kz65llpobkwiktchibtuu/node_modules/@nx/jest/src/generators/init/init.js:5:18)
Package Manager Version
No response
Operating System
- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)
Additional Information
No response
@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?
Also, this shouldn't be just scope: nextjs. It happens for Node as well, and various other generators.
This broke an internal plugin which started using the project crystal stuff as the code examples showed using projectGraphCacheDirectory to cache the results.
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\@[email protected]_@[email protected][email protected][email protected][email protected][email protected]\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\[email protected]\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\@[email protected]_@[email protected][email protected][email protected][email protected][email protected]\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.
I'd love to know what should I do actually being stopped by this - use older version? which one?
I am approaching nx probably fourth time during last two years and always struggling with errors like this...
All of our internal generator broke after migrating to v19 or v20. This is a huge blocker that is keeping us on v18 for quite some time.
This issue has been automatically marked as stale because it hasn't had any activity for 6 months. Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore. If at this point, this is still an issue, please respond with updated information. It will be closed in 21 days if no further activity occurs. Thanks for being a part of the Nx community! 🙏
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.