-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Format commands fail using Prettier v3 on NX 16.7.3 #18791
Comments
I see that #18664 was recently merged for prettier 3 compatibility, this implies nx supports prettier 3. My issue already seems to be resolved by #18644 and improved by @Michsior14 in #18672 but according to #18721 errors occur.
@AgentEnder maybe better to release the prettier fix in 16.7.4? |
This seems to be kind of duplicate of #17990. |
Can you please try again with |
@Michsior14 you are right, didn't find that issue since it was closed already while the 16.7.3 and 16.8.0.beta.2 were not fully compatible with Prettier 3 yet (the beta.2 gives the error stated in #18721) @FrozenPandaz I removed my patch and Thanks and apologies in case I caused some noise by opening a new issue for this. |
@pvds I don't believe this has been resolved. when running var prettierPromise = import("./index.mjs");
^
TypeError: Invalid host defined options
at Object.<anonymous> (/<HIDDEN>/node_modules/.pnpm/prettier@3.0.3/node_modules/prettier/index.cjs:600:23)
at Module._compile (/<HIDDEN>/node_modules/.pnpm/v8-compile-cache@2.3.0/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Module.require (node:internal/modules/cjs/loader:1115:19)
at Mod.require (/<HIDDEN>/node_modules/.pnpm/nx@16.7.4_@swc+core@1.3.81/node_modules/nx/bin/init-local.js:203:36)
at require (/<HIDDEN>/node_modules/.pnpm/v8-compile-cache@2.3.0/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at Object.<anonymous> (/<HIDDEN>/node_modules/.pnpm/nx@16.7.4_@swc+core@1.3.81/node_modules/nx/src/command-line/format/format.js:11:18)
at Module._compile (/<HIDDEN>/node_modules/.pnpm/v8-compile-cache@2.3.0/node_modules/v8-compile-cache/v8-compile-cache.js:192:30) output of > NX Report complete - copy this into the issue template
Node : 20.5.1
OS : darwin-x64
pnpm : 8.7.0
nx : 16.7.4
@nx/js : 16.7.4
@nx/jest : 16.7.4
@nx/linter : 16.7.4
@nx/workspace : 16.7.4
@nx/cypress : 16.7.4
@nx/devkit : 16.7.4
@nx/eslint-plugin : 16.7.4
@nx/next : 16.7.4
@nx/react : 16.7.4
@nrwl/tao : 16.7.4
@nx/web : 16.7.4
nx-cloud : 16.3.0
typescript : 5.2.2
---------------------------------------
Community plugins:
@koliveira15/nx-sonarqube : 3.1.1
nx-stylelint : 15.0.0 |
@gcko After Googling on As it turns out Since I could not actually remove So the following did the trick for me on the command-line:
|
Nice sleuthing, @evangalen ! I'll give it a try 🙏 --- EDIT --- And lo' and behold, IT WORKS! Thanks for this! 🥇 |
Confirming both that the issue remains and that the DISABLE_V8_COMPILE_CACHE=1 fixes it. Should this be reopened @FrozenPandaz ? |
There is a fix merged that will be in the next release for the v8 compile cache |
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. |
Current Behavior
When running
nx format:check
ornx format:write
the following error is thrown:Cannot find module '/monorepo/node_modules/prettier/bin-prettier'
This is because Prettier 3 changed the node_module structure as documented in the Prettier 3 release notes.
So this is the fix to support Prettier 3, not taking in account backwards compatibility with older prettier versions:
-const PRETTIER_PATH = require.resolve('prettier/bin-prettier');
+const PRETTIER_PATH = require.resolve('prettier/bin/prettier.cjs');
Expected Behavior
Correct prettier 3 path is used, possibly with backwards compatibility for the prettier 2 path.
GitHub Repo
https://github.com/nrwl/nx-examples with nx 16.7.3 and prettier 3
Steps to Reproduce
test/nx-prettier-3
branchnx format:check
ornx format:write
Nx Report
Failure Logs
Operating System
Additional Information
For reference this is the current patch i'm using:
The text was updated successfully, but these errors were encountered: