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

Version 4: Invalid prettier configuration detected when using a config from an npm package. #1292

Closed
Lusito opened this issue Apr 4, 2020 · 2 comments
Labels
locked Please open a new issue and fill out the template instead of commenting.

Comments

@Lusito
Copy link

Lusito commented Apr 4, 2020

Summary

I use .prettierrc.json to load my prettier-config from node_modules. This works in command line prettier.

When I try to use the formatter, however, it fails, telling me my prettier config is invalid.
Cannot find module '@lusito/prettier-config' from '<my-root-path>'

Github Repository to Reproduce Issue

Link to a Github repo that can be used to reproduce the issue.

Steps To Reproduce:

  1. Create an NPM project
  2. Install a prettier config, for example mine: @lusito/prettier-config.
  3. Create a .prettierrc.json with content "@lusito/prettier-config"
  4. Use prettier code-formatter => boom

Expected result

It should work just like the CLI

Actual result

An error message shows up

Additional information

VS Code Version: 1.43.2

Prettier Extension Version: 4.0.0. It works when I switch back to 3.2.0 (though trailing commas seems to be different for some reason)

OS and version: Win7

Prettier Log Output

["INFO" - 12:42:03] Extension Name: "prettier-vscode".
["INFO" - 12:42:03] Extension Version: "4.0.0".
["INFO" - 12:42:03] Enabling prettier for languages
[
  "css",
  "graphql",
  "html",
  "javascript",
  "javascriptreact",
  "json",
  "json5",
  "jsonc",
  "less",
  "markdown",
  "mdx",
  "mongo",
  "postcss",
  "scss",
  "typescript",
  "typescriptreact",
  "vue",
  "yaml"
]
["INFO" - 12:42:03] Enabling prettier for range supported languages
[
  "graphql",
  "javascript",
  "javascriptreact",
  "json",
  "typescript",
  "typescriptreact"
]
["INFO" - 12:42:04] Formatting <my-root-path>\src\setupTests.ts
["ERROR" - 12:42:04] Invalid prettier configuration file detected.
["ERROR" - 12:42:04] Cannot find module '@lusito/prettier-config' from '<my-root-path>'
Error: Cannot find module '@lusito/prettier-config' from '<my-root-path>'
	at Function.Module._resolveFilename (internal/modules/cjs/loader.js:717:15)
	at Function.n.resolve (c:\Users\Lusito\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:584)
	at Object.transform (<my-vscode-path>\extensions\esbenp.prettier-vscode-4.0.0\node_modules\prettier\index.js:23283:40)
	at run (<my-vscode-path>\extensions\esbenp.prettier-vscode-4.0.0\node_modules\prettier\third-party.js:11472:51)
	at async cacheWrapper (<my-vscode-path>\extensions\esbenp.prettier-vscode-4.0.0\node_modules\prettier\third-party.js:11300:20)
	at async cacheWrapper (<my-vscode-path>\extensions\esbenp.prettier-vscode-4.0.0\node_modules\prettier\third-party.js:11300:20)
	at async Explorer.search (<my-vscode-path>\extensions\esbenp.prettier-vscode-4.0.0\node_modules\prettier\third-party.js:11457:22)
	at async Promise.all (index 0)
["INFO" - 12:57:01] Formatting <my-root-path>\src\setupTests.ts
["ERROR" - 12:57:01] Invalid prettier configuration file detected.
["ERROR" - 12:57:01] Cannot find module '@lusito/prettier-config' from '<my-root-path>'
Error: Cannot find module '@lusito/prettier-config' from '<my-root-path>'
	at Function.Module._resolveFilename (internal/modules/cjs/loader.js:717:15)
	at Function.n.resolve (c:\Users\Lusito\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:584)
	at Object.transform (<my-vscode-path>\extensions\esbenp.prettier-vscode-4.0.0\node_modules\prettier\index.js:23283:40)
	at run (<my-vscode-path>\extensions\esbenp.prettier-vscode-4.0.0\node_modules\prettier\third-party.js:11472:51)
	at async cacheWrapper (<my-vscode-path>\extensions\esbenp.prettier-vscode-4.0.0\node_modules\prettier\third-party.js:11300:20)
	at async cacheWrapper (<my-vscode-path>\extensions\esbenp.prettier-vscode-4.0.0\node_modules\prettier\third-party.js:11300:20)
	at async Explorer.search (<my-vscode-path>\extensions\esbenp.prettier-vscode-4.0.0\node_modules\prettier\third-party.js:11457:22)
	at async Promise.all (index 0)
@ntotten
Copy link
Member

ntotten commented Apr 4, 2020

Duplicate of #1289

@ntotten ntotten marked this as a duplicate of #1289 Apr 4, 2020
@ntotten ntotten closed this as completed Apr 4, 2020
@github-actions
Copy link

github-actions bot commented Jul 3, 2020

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 github-actions bot added the locked Please open a new issue and fill out the template instead of commenting. label Jul 3, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

2 participants