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

[v3] [error] Cannot find package plugin-name imported from /.../root-project/noop.js #15085

Closed
vighnesh153 opened this issue Jul 12, 2023 · 4 comments
Labels
area:plugin api status:awaiting response Issues that require answers to questions from maintainers before action can be taken status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug

Comments

@vighnesh153
Copy link

Environments:

  • Prettier Version: 3.0.0
  • Running Prettier via: CLI
  • Runtime: Node.js v18
  • Operating System: macOS
  • Prettier plugins (if any): prettier-plugin-tailwindcss

Steps to reproduce:

Minimal reproducible repo: https://github.com/vighnesh153/prettier-unable-to-find-pkg

  • Install deps
# Install in prettier-config directory
cd prettier-config && npm install
cd ..
# Install in root directory
npm install
  • Run npx prettier --write . from the root directory

Checked with the plugin's project and they suspect the issue is with prettier v3: tailwindlabs/prettier-plugin-tailwindcss#176 (comment)

Expected behavior:
Prettier should work without throwing the following error as this works with v2.8.8

Actual behavior:

[error] Cannot find package 'prettier-plugin-tailwindcss' imported from /.../prettier-unable-to-find-pkg/noop.js
@fisker fisker added type:bug Issues identifying ugly output, or a defect in the program status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug labels Jul 12, 2023
@fisker
Copy link
Member

fisker commented Jul 13, 2023

As I tested, this doesn't work in v2.

The plugin should be resolvable from your CWD, or related to the prettier config file, which is ./package.json in your case.

@fisker fisker added status:awaiting response Issues that require answers to questions from maintainers before action can be taken and removed type:bug Issues identifying ugly output, or a defect in the program status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug labels Jul 13, 2023
@vighnesh153
Copy link
Author

vighnesh153 commented Jul 13, 2023

Sorry, this seems to be working in v2. Have pushed a v2 branch to demonstrate the behaviour..

https://github.com/vighnesh153/prettier-unable-to-find-pkg/tree/v2

Please delete node_modules and package-lock.json in both directories before running npm install.

@github-actions github-actions bot removed the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Jul 13, 2023
@fisker
Copy link
Member

fisker commented Jul 13, 2023

You are right, your v2 branch works, but I don't know why. There should be something to do with npm.

v2

$ ls node_modules/
prettier  prettier-config  prettier-plugin-tailwindcss

main

$  ls node_modules/
prettier  prettier-config

@sosukesuzuki sosukesuzuki added type:bug Issues identifying ugly output, or a defect in the program status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug area:plugin api labels Jul 16, 2023
@fisker
Copy link
Member

fisker commented Jul 16, 2023

Just to be clear, we didn't expect this case work in v2, we can't guarantee a transitive dependency to be solved, it just happened works somehow.

I don't think we will do anything, you can use one of the following js config

plugins:[
  require.resolve("prettier-plugin-tailwindcss")
]
plugins:[
  import.meta.resolve("prettier-plugin-tailwindcss")
]
plugins:[
  require("prettier-plugin-tailwindcss")
]
plugins:[
  await import("prettier-plugin-tailwindcss")
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:plugin api status:awaiting response Issues that require answers to questions from maintainers before action can be taken status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug
Projects
None yet
Development

No branches or pull requests

3 participants