Skip to content

Plugin API not working with globally installed modules #4000

@czosel

Description

@czosel

Currently, globally installed plugins don't seem to be discovered by the CLI:

npm install -g prettier @prettier/plugin-php
prettier --plugin=@prettier/plugin-php --parser=php test.php
# Error: Cannot find module '@prettier/plugin-php'

npm init --yes
npm install prettier @prettier/plugin-php
prettier --plugin=@prettier/plugin-php --parser=php test.php
# works

It seems that read-pkg-up is just looking for the closest package.json file, which doesn't work for global installs

const readPkgUp = require("read-pkg-up");

(in case you're wondering why i'm explicitly passing the plugin: There also seems to be an issue with automatic discovery, running the command without results in SyntaxError: Unexpected token (see prettier/plugin-php#55))

Metadata

Metadata

Assignees

No one assigned

    Labels

    locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions