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 plugins cannot be resolved when package.json is not in the root folder #470

Open
1 task done
grofzero opened this issue Sep 4, 2023 · 1 comment
Open
1 task done
Labels
type: bug a problem with a feature or rule

Comments

@grofzero
Copy link

grofzero commented Sep 4, 2023

How did you encounter this bug?

I have a project in the frontend folder which is not the root of the project. I use vue, prettier and pug. I use @prettier/plugin-pug to format pug. So my prettier config looks like this:

{ "plugins": ["@prettier/plugin-pug"], "printWidth": 120, "pugPrintWidth": 500, "pugUseTabs": true, "singleQuote": true, "pugSingleQuote": false, "semi": true, "useTabs": true, "tabWidth": 4, "endOfLine": "auto", "trailingComma": "none" }

I use 'stylelint-prettier' to format the css parts with prettier.

When I try to format an scss file with vs code it show an error "Error: Cannot find package '@prettier/plugin-pug'"

When I run stylelint from my frontend folder it runs fine.

Link to Minimal Reproducible Example

https://github.com/grofzero/stylelint-prettier-test

Code Snippet

No response

Stylelint Configuration

{
	"extends": [
		"stylelint-config-standard-scss", "stylelint-config-recommended-vue/scss"
	],
	"plugins": [
		"stylelint-prettier"
	],
	"overrides": [
		{
		  "files": [
				"**/*.scss", "**/*.vue"
			]
		}
	],
	"rules": {
		"prettier/prettier": true,
		"max-nesting-depth": 4,
		"at-rule-no-unknown": null
	}
}

Extension Configuration

No response

Actual Behaviour

Error: Cannot find package '@prettier/plugin-pug

Expected Behaviour

To format the scss.

Logs

Error: Cannot find package '@prettier/plugin-pug' imported from /home/kornel/workspace-mt/stylelint-prettier-test/noop.js at new NodeError (file:///home/kornel/workspace-mt/stylelint-prettier-test/frontend/node_modules/prettier/index.mjs:18797:5) at packageResolve (file:///home/kornel/workspace-mt/stylelint-prettier-test/frontend/node_modules/prettier/index.mjs:19742:9) at moduleResolve (file:///home/kornel/workspace-mt/stylelint-prettier-test/frontend/node_modules/prettier/index.mjs:19774:20) at defaultResolve (file:///home/kornel/workspace-mt/stylelint-prettier-test/frontend/node_modules/prettier/index.mjs:19879:15) at resolve (file:///home/kornel/workspace-mt/stylelint-prettier-test/frontend/node_modules/prettier/index.mjs:19897:12) at importFromFile (file:///home/kornel/workspace-mt/stylelint-prettier-test/frontend/node_modules/prettier/index.mjs:19912:15) at importFromDirectory (file:///home/kornel/workspace-mt/stylelint-prettier-test/frontend/node_modules/prettier/index.mjs:20181:10) at file:///home/kornel/workspace-mt/stylelint-prettier-test/frontend/node_modules/prettier/index.mjs:20198:12 at async loadPlugin (file:///home/kornel/workspace-mt/stylelint-prettier-test/frontend/node_modules/prettier/index.mjs:20203:28) at async Promise.all (index 0)

Stylelint Version

15.10.3

vscode-stylelint Version

1.2.4

Node.js Version

v18.14.0

Operating System

Ubuntu 22.04.3 LTS

Windows Subsystem for Linux

No response

Code of Conduct

  • I agree to follow vscode-stylelint's Code of Conduct
@grofzero grofzero added the type: bug a problem with a feature or rule label Sep 4, 2023
@DariushStony
Copy link

I have the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug a problem with a feature or rule
Projects
None yet
Development

No branches or pull requests

2 participants