Skip to content
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

🐞 bug: prettier 3 error Invalid host defined options #18721

Closed
1 of 4 tasks
Yberion opened this issue Aug 19, 2023 · 15 comments · Fixed by #19042 or #19075
Closed
1 of 4 tasks

🐞 bug: prettier 3 error Invalid host defined options #18721

Yberion opened this issue Aug 19, 2023 · 15 comments · Fixed by #19042 or #19075
Assignees

Comments

@Yberion
Copy link

Yberion commented Aug 19, 2023

Current Behavior

When trying to format the code with prettier 3, I'm getting an error (check log below).

I'm not sure if it's related to nx or another package (prettier itselft probably), I found this issue prettier/prettier#15098 & prettier/prettier-vscode#3114 and I'm not able to reproduce on nx-examples or another Angular project (using nx as well).


Expected Behavior

Formatting without errors.


GitHub Repo

https://github.com/Yberion/image-utils/tree/feature/prettier3


Steps to Reproduce

  1. pnpm install --no-frozen-lockfile
  2. pnpm run format

Nx Report

>  NX  Falling back to ts-node for local typescript execution. This may be a little slower.
  - To fix this, ensure @swc-node/register and @swc/core have been installed

 >  NX   Report complete - copy this into the issue template

   Node   : 20.5.0
   OS     : win32-x64
   pnpm   : 8.6.12

   nx                 : 16.8.0-beta.0
   @nx/js             : 16.8.0-beta.0
   @nx/linter         : 16.8.0-beta.0
   @nx/workspace      : 16.8.0-beta.0
   @nx/devkit         : 16.8.0-beta.0
   @nx/esbuild        : 16.8.0-beta.0
   @nx/eslint-plugin  : 16.8.0-beta.0
   @nrwl/tao          : 16.8.0-beta.0
   @nx/vite           : 16.8.0-beta.0
   typescript         : 5.1.6

Failure Logs

E:\Git\myberion\image-utils\node_modules\.pnpm\prettier@3.0.2\node_modules\prettier\index.cjs:600
var prettierPromise = import("./index.mjs");
                      ^

TypeError: Invalid host defined options
    at Object.<anonymous> (E:\Git\myberion\image-utils\node_modules\.pnpm\prettier@3.0.2\node_modules\prettier\index.cjs:600:23)
    at Module._compile (E:\Git\myberion\image-utils\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 (E:\Git\myberion\image-utils\node_modules\.pnpm\nx@16.8.0-beta.0\node_modules\nx\bin\init-local.js:203:36)
    at require (E:\Git\myberion\image-utils\node_modules\.pnpm\v8-compile-cache@2.3.0\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (E:\Git\myberion\image-utils\node_modules\.pnpm\nx@16.8.0-beta.0\node_modules\nx\src\command-line\format\format.js:10:18)
    at Module._compile (E:\Git\myberion\image-utils\node_modules\.pnpm\v8-compile-cache@2.3.0\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)

Node.js v20.5.0
 ELIFECYCLE  Command failed with exit code 1.

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@Yberion Yberion changed the title 🐞bug: prettier 3 error Invalid host defined options 🐞 bug: prettier 3 error Invalid host defined options Aug 19, 2023
@FaresKi
Copy link

FaresKi commented Aug 20, 2023

I believe nx is currently not able to work with prettier 3, and thus why it breaks

@Yberion
Copy link
Author

Yberion commented Aug 20, 2023

Hello, it should properly work as of 16.8.0-beta.0.

(edit: I was replying to @FaresKi, I'm still facing the problem on latest version of nx)

@Suyashtnt
Copy link

Hello, it should properly work as of 16.8.0-beta.0.

Upgraded to 16.8.0-beta.2. Still have it
image

@sauldeleon
Copy link

Fails to me as well, latest nrwl and nx and prettier!

@cereum
Copy link

cereum commented Aug 26, 2023

likewise

nx/*: 16.8.0-beta.3,
@swc-node/register: ^1.6.7,
@swc/core: ^1.3.80,

TypeError: Invalid host defined options
    at Object.<anonymous> (/Users/cereum/cfx/cfx-b2b-services/node_modules/.pnpm/prettier@3.0.2/node_modules/prettier/index.cjs:600:23)
    at Module._compile (/Users/cereum/cfx/cfx-b2b-services/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 (/Users/cereum/cfx/cfx-b2b-services/node_modules/.pnpm/nx@16.8.0-beta.3_@swc-node+register@1.6.7_@swc+core@1.3.80/node_modules/nx/bin/init-local.js:203:36)
    at require (/Users/cereum/cfx/cfx-b2b-services/node_modules/.pnpm/v8-compile-cache@2.3.0/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/Users/cereum/cfx/cfx-b2b-services/node_modules/.pnpm/nx@16.8.0-beta.3_@swc-node+register@1.6.7_@swc+core@1.3.80/node_modules/nx/src/command-line/format/format.js:11:18)
    at Module._compile (/Users/cereum/cfx/cfx-b2b-services/node_modules/.pnpm/v8-compile-cache@2.3.0/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)

Node.js v20.5.1

@guysenpai
Copy link
Contributor

you can set DISABLE_V8_COMPILE_CACHE environment variable before execute command

DISABLE_V8_COMPILE_CACHE=1 nx format:write

@igilham
Copy link

igilham commented Sep 8, 2023

This is not fixed in Nx 16.8.1

yarn nx report

 >  NX   Report complete - copy this into the issue template

   Node   : 18.12.1
   OS     : darwin-arm64
   yarn   : 3.5.1
   
   nx             : 16.8.1
   @nx/workspace  : 16.8.1
   @nx/devkit     : 16.8.1
   @nrwl/tao      : 16.8.1
   nx-cloud       : 16.4.0
   typescript     : 4.9.5

Error

yarn nx format:check
/Users/ian/code/newsletter/node_modules/prettier/index.cjs:600
var prettierPromise = import("./index.mjs");
                      ^

TypeError: Invalid host defined options
    at Object.<anonymous> (/Users/ian/code/newsletter/node_modules/prettier/index.cjs:600:23)
    at Module._compile (/Users/ian/code/newsletter/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at Mod.require (/Users/ian/code/newsletter/node_modules/nx/bin/init-local.js:203:36)
    at require (/Users/ian/code/newsletter/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/Users/ian/code/newsletter/node_modules/nx/src/command-line/format/format.js:10:18)
    at Module._compile (/Users/ian/code/newsletter/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)

Node.js v18.12.1

Prettier and related dependencies:

"prettier": "^3.0.3",
"eslint-plugin-prettier": "^5.0.0",
"eslint-config-prettier": "^9.0.0",
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"eslint": "^8.44.0",

@khalilou88
Copy link
Contributor

same error

@AgentEnder
Copy link
Member

This PR hasn't been released yet, so you'll still get the error. #19075

@khalilou88
Copy link
Contributor

thanks fixed in version 16.9

@ryanhefner
Copy link

Really? I am still seeing the error in 16.10.0... Any other potential tricks to fix this one?

@AgentEnder
Copy link
Member

What command are you running that leads to you hitting the errror?

@ryanhefner
Copy link

@AgentEnder Just trying to spin up a new @nx/js lib.

nx g @nx/js:lib types --directory libs/types --bundler rollup

@avalero1985
Copy link

Until it is fixed, I have simply downgraded from prettier to version 2.8.8 and it has worked for me:

"devDependencies": {
  ...
  "prettier": "2.8.8",
  ...
},

Copy link

github-actions bot commented Dec 9, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.