prettier-vscode icon indicating copy to clipboard operation
prettier-vscode copied to clipboard

Command 'Format Document With...' resulted in an error (command 'npm.packageManager' not found)

Open khanakia opened this issue 4 years ago • 7 comments

Summary

It does works first them when i reinstall the extension. But when i reload the VS CODE it stops working again.

Github Repository to Reproduce Issue

Just use any Javascript File

Steps To Reproduce:

  1. CMD + SHIFT + P
  2. Format Document With
  3. Prettier Code Formatter

Expected result

It should format the code

Actual result

It's giving error Command 'Format Document With...' resulted in an error (command 'npm.packageManager' not found)

Additional information

Feel free to attach a screenshot. Screenshot 2021-04-27 at 9 12 11 PM

VS Code Version: 1.55.2

Prettier Extension Version: 6.3.2

OS and version: OSX Catalina 10.15.6 (19G73

Prettier Log Output

["INFO" - 9:06:10 PM] Extension Name: esbenp.prettier-vscode.
["INFO" - 9:06:10 PM] Extension Version: 6.3.2.
["INFO" - 9:06:12 PM] Formatting /Volumes/D/www/php/wordpress/wp-content/plugins/analyzify/assets/analyzify-frontend.js
["INFO" - 9:06:12 PM] Using ignore file (if present) at /Volumes/D/www/php/wordpress/.prettierignore
["INFO" - 9:09:33 PM] Formatting /Volumes/D/www/php/wordpress/wp-content/plugins/analyzify/assets/analyzify-frontend.js
["INFO" - 9:09:33 PM] Using ignore file (if present) at /Volumes/D/www/php/wordpress/.prettierignore

khanakia avatar Apr 27 '21 15:04 khanakia

I am not able to reproduce this issue. A lot of the time these issues are caused by various version and config settings that are difficult to duplicate. Please provide a sample Github repo that I can use to duplicate this issue. For more details see this guide.

ntotten avatar Apr 28 '21 02:04 ntotten

@ntotten check this repo https://github.com/khanakia/prettier_issue

Here's the debug Log

["INFO" - 8:32:50 AM] Extension Name: esbenp.prettier-vscode.
["INFO" - 8:32:50 AM] Extension Version: 6.3.2.
["INFO" - 8:32:50 AM] Enabling Prettier globally
{
  "languageSelector": [
    {
      "language": "javascript",
      "scheme": "file"
    },
    {
      "language": "mongo",
      "scheme": "file"
    },
    {
      "language": "javascriptreact",
      "scheme": "file"
    },
    {
      "language": "typescript",
      "scheme": "file"
    },
    {
      "language": "typescriptreact",
      "scheme": "file"
    },
    {
      "language": "json",
      "scheme": "file"
    },
    {
      "language": "jsonc",
      "scheme": "file"
    },
    {
      "language": "json5",
      "scheme": "file"
    },
    {
      "language": "css",
      "scheme": "file"
    },
    {
      "language": "postcss",
      "scheme": "file"
    },
    {
      "language": "less",
      "scheme": "file"
    },
    {
      "language": "scss",
      "scheme": "file"
    },
    {
      "language": "graphql",
      "scheme": "file"
    },
    {
      "language": "markdown",
      "scheme": "file"
    },
    {
      "language": "mdx",
      "scheme": "file"
    },
    {
      "language": "html",
      "scheme": "file"
    },
    {
      "language": "vue",
      "scheme": "file"
    },
    {
      "language": "yaml",
      "scheme": "file"
    },
    {
      "language": "ansible",
      "scheme": "file"
    },
    {
      "language": "home-assistant",
      "scheme": "file"
    },
    {
      "language": "javascript",
      "scheme": "untitled"
    },
    {
      "language": "mongo",
      "scheme": "untitled"
    },
    {
      "language": "javascriptreact",
      "scheme": "untitled"
    },
    {
      "language": "typescript",
      "scheme": "untitled"
    },
    {
      "language": "typescriptreact",
      "scheme": "untitled"
    },
    {
      "language": "json",
      "scheme": "untitled"
    },
    {
      "language": "jsonc",
      "scheme": "untitled"
    },
    {
      "language": "json5",
      "scheme": "untitled"
    },
    {
      "language": "css",
      "scheme": "untitled"
    },
    {
      "language": "postcss",
      "scheme": "untitled"
    },
    {
      "language": "less",
      "scheme": "untitled"
    },
    {
      "language": "scss",
      "scheme": "untitled"
    },
    {
      "language": "graphql",
      "scheme": "untitled"
    },
    {
      "language": "markdown",
      "scheme": "untitled"
    },
    {
      "language": "mdx",
      "scheme": "untitled"
    },
    {
      "language": "html",
      "scheme": "untitled"
    },
    {
      "language": "vue",
      "scheme": "untitled"
    },
    {
      "language": "yaml",
      "scheme": "untitled"
    },
    {
      "language": "ansible",
      "scheme": "untitled"
    },
    {
      "language": "home-assistant",
      "scheme": "untitled"
    },
    {
      "language": "jsonc",
      "scheme": "vscode-userdata"
    }
  ],
  "rangeLanguageSelector": [
    {
      "language": "javascript",
      "scheme": "file"
    },
    {
      "language": "javascriptreact",
      "scheme": "file"
    },
    {
      "language": "typescript",
      "scheme": "file"
    },
    {
      "language": "typescriptreact",
      "scheme": "file"
    },
    {
      "language": "json",
      "scheme": "file"
    },
    {
      "language": "graphql",
      "scheme": "file"
    },
    {
      "language": "javascript",
      "scheme": "untitled"
    },
    {
      "language": "javascriptreact",
      "scheme": "untitled"
    },
    {
      "language": "typescript",
      "scheme": "untitled"
    },
    {
      "language": "typescriptreact",
      "scheme": "untitled"
    },
    {
      "language": "json",
      "scheme": "untitled"
    },
    {
      "language": "graphql",
      "scheme": "untitled"
    }
  ]
}
["INFO" - 8:32:53 AM] Formatting /Users/khanakia/Downloads/prettier_issue/demo.js
["INFO" - 8:32:53 AM] Using ignore file (if present) at /Users/khanakia/Downloads/prettier_issue/.prettierignore

khanakia avatar Apr 28 '21 03:04 khanakia

@ntotten I think i found the issue 👍 when i have this config is set to true "prettier.resolveGlobalModules": true then it gives the above mentioned error.

So please enable that setting and then test it also i am attaching the vscode settings.json file settings.json

khanakia avatar Apr 28 '21 03:04 khanakia

Thanks for the added info. I'll check this ASAP and get a fix out. Hopefully in the next few days.

ntotten avatar May 03 '21 12:05 ntotten

I am having the same issue on Arch Linux. Node installed with nvm. Integrated terminal shows correct node and nvm versions, so vscode seems to be aware of them. Added this to .bash_profile

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

and this to settings.json:

"terminal.integrated.shellArgs.linux": ["-l"]

Still no luck. Also having "prettier.resolveGlobalModules": true in my settings

gebeer avatar Jun 27 '21 08:06 gebeer

I'm having the same issue.

In my case, this occurs when package.json is not in the root folder. Eg,

<root>
└── app
    ├── package.json
    └── index.js

frosas avatar Oct 28 '21 09:10 frosas

@ntotten I think i found the issue 👍 when i have this config is set to true "prettier.resolveGlobalModules": true then it gives the above mentioned error.

So please enable that setting and then test it also i am attaching the vscode settings.json file settings.json

This resolved it for me, thanks.

asheroto avatar Feb 23 '22 09:02 asheroto

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

github-actions[bot] avatar Apr 22 '23 14:04 github-actions[bot]

happened today, julia 1.8.5

Command 'Format Document With...' resulted in an error

Failed to format document: ErrorException("Error while PARSING formatted text:\n\n1   using LinearAlgebra\n2 .....

luboshanus avatar Apr 26 '23 12:04 luboshanus

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

github-actions[bot] avatar Jun 26 '23 02:06 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Oct 03 '23 00:10 github-actions[bot]