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

Unable to run prettierd run with a prettierrc configuration. #175

Open
niyabits opened this issue May 11, 2021 · 15 comments
Open

Unable to run prettierd run with a prettierrc configuration. #175

niyabits opened this issue May 11, 2021 · 15 comments
Labels
bug Something isn't working

Comments

@niyabits
Copy link

Prettierd runs fine when I provide no .prettierrc.json, but when I add the file in my root I get the following error -

C:\Users\yashg\AppData\Local\nvim>prettierd test\foo.ts
TypeError [ERR_INVALID_ARG_TYPE]: The "list" argument must be an instance of Array. Received null
    at Function.concat (buffer.js:550:11)
    at Object.readFileAfterClose (internal/fs/read_file_context.js:51:23)
    at tick (internal/fs/read_file_context.js:105:28)
    at processTicksAndRejections (internal/process/task_queues.js:79:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}

I am using Neovim in Windows along with efm-language-server
My configuration of prettier looks like -

{formatCommand = "prettierd ${INPUT}", formatStdin = true}

Any idea?

@fsouza
Copy link
Owner

fsouza commented May 11, 2021

🤔 this should work, or at least it used to. I'll dig into it, but can you share your prettier config to help reproducing the error message? Thanks!

@niyabits
Copy link
Author

niyabits commented May 14, 2021

🤔 this should work, or at least it used to. I'll dig into it, but can you share your prettier config to help reproducing the error message? Thanks!

Maybe it's a windows thing?

{
  "endOfLine": "lf",
  "semi": true,
  "singleQuote": false,
  "tabWidth": 2,
  "trailingComma": "es5"
}

@fsouza
Copy link
Owner

fsouza commented May 14, 2021

🤔 this should work, or at least it used to. I'll dig into it, but can you share your prettier config to help reproducing the error message? Thanks!

Maybe it's a windows thing?

{
  "endOfLine": "lf",
  "semi": true,
  "singleQuote": false,
  "tabWidth": 2,
  "trailingComma": "es5"
}

Thanks for sharing the config, I'll investigate it later this week.

@fsouza fsouza added the bug Something isn't working label Jul 15, 2021
@jorgerojas26
Copy link

Any fix for this? i'm having the exact same problem on Windows 11.

@fsouza
Copy link
Owner

fsouza commented Dec 1, 2021

Any fix for this? i'm having the exact same problem on Windows 11.

I haven't had a chance to look into this yet 😞 I don't have access to a Windows machine, but my plan was to try to reproduce it with GitHub Actions or something like that.

@jvmiert
Copy link

jvmiert commented Jan 26, 2022

Let me start by expressing my thanks for making this available @fsouza.

Also ran into this issue. It used to all work fine but now I can't get it to work on Windows 10 (with or without config file).

It seems to fail on this function: readFile(process.stdin.fd, { encoding: "utf-8" }).

node .\dist\prettierd.js "asgasg"
action: INVOKE_CORE_D
cmdOrFilename: asgasg
args: [ 'asgasg' ]
TypeError [ERR_INVALID_ARG_TYPE]: The "list" argument must be an instance of Array. Received null
    at Function.concat (node:buffer:536:3)
    at Object.readFileAfterClose (node:internal/fs/read_file_context:56:23)
    at tick (node:internal/fs/read_file_context:115:9)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Not really sure where to go from here. Any hints would be appreciated.

Is this maybe related? nodejs/node#19831

EDIT: If I change the efm-langserver command to:
{ formatCommand = 'prettierd ${INPUT}', formatStdin = true }
instead of:
{ formatCommand = 'prettierd --stdin-filepath ${INPUT}', formatStdin = true }
everything works fine.

@fsouza
Copy link
Owner

fsouza commented Jan 27, 2022

@jvmiert is "asgasg" a file? Can you try running it on an actual js file? Something like prettierd file.js <file.js

@jvmiert
Copy link

jvmiert commented Jan 29, 2022

Ah sorry, inputting a valid file yields the exact same result.

@fsouza
Copy link
Owner

fsouza commented Jan 29, 2022

Can you share the output of when you call it with valid files? The output you shared is complaining about "asgasg" being an invalid argument.

@jvmiert
Copy link

jvmiert commented Jan 30, 2022

...\frontend\pages› prettierd.cmd .\login.tsx
TypeError [ERR_INVALID_ARG_TYPE]: The "list" argument must be an instance of Array. Received null
    at Function.concat (node:buffer:536:3)
    at Object.readFileAfterClose (node:internal/fs/read_file_context:56:23)
    at tick (node:internal/fs/read_file_context:115:9)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}

@fsouza
Copy link
Owner

fsouza commented Jan 31, 2022

@jvmiert I'll try to spin up a windows vm to investigate this. Sorry for the back and forth.

@JerryLiao26
Copy link

@fsouza Are there any updates on this issue? Thanks

@fsouza
Copy link
Owner

fsouza commented Aug 23, 2022

@JerryLiao26 hey, I haven't been able to work on this yet, apologies :( No idea either on when I'll be able to spin up a Windows VM and investigate the issue, but I'm hoping I'll be able to do something like that over the next week or two.

@JerryLiao26
Copy link

@JerryLiao26 hey, I haven't been able to work on this yet, apologies :( No idea either on when I'll be able to spin up a Windows VM and investigate the issue, but I'm hoping I'll be able to do something like that over the next week or two.

@fsouza Really appreciated! I've managed to make prettierd work by using other lsp plugins but I'm willing to provide help if you need some more information

@elentok
Copy link

elentok commented Sep 7, 2022

Not sure if this is related but I ran into a similar issue earlier today. I think I upgraded it while an old prettierd server was still running. After running prettierd stop and trying again it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants