Skip to content

Unable to load plugin (yarn pnp issue?) #4367

Open

Description

@maddrag0n

To reproduce:

import { execSync } from 'node:child_process';

execSync(
  'lessc --clean-css="--s1 --advanced --compatibility=ie8" index.less style.css',
  { stdio: 'inherit' },
);

Current behavior:

It seems that less cannot find clean-css.

Unable to load plugin clean-css please make sure that it is installed under or at the same level as less

Expected behavior:

Expected that less would find clean-css.

Environment information:

  • less version: 4.4.1
  • nodejs version: v22.15.0
  • operating system: macos 14.6.1 (23G93)
  • yarn version: 4.9.1
  • less-plugin-clean-css version: 1.6.0
  • clean-css version: 5.3.3

Additional context

  • packages installed as dev deps (yarn add -D) in yarn workspace using pnp
  • script is run with yarn dotenvx run tsx ./script.ts

Activity

  1. dosubot commented on Sep 17, 2025

    @dosubot

    Less uses Node's require function to load plugins, starting from the current working directory. This approach doesn't account for Yarn PnP's virtual resolution, which means plugins like less-plugin-clean-css may not be found unless they're exposed in a way compatible with Node's require logic. The Less codebase does not have explicit support for Yarn PnP in its plugin loader, so this error is expected in PnP setups where node_modules aren't present and require paths are virtualized. You may need to use a workaround such as running lessc through pnpify, or configuring your workspace so that the plugin is resolvable from the CLI context. There are no documented configuration options or environment variables in Less for custom plugin resolution paths under Yarn PnP as of now.
    PluginLoader code reference
    lessc CLI plugin loading logic

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about less.js Share Dosu with your team

  2. maddrag0n commented on Sep 17, 2025

    @maddrag0n
    Author

    neither yarn lessc … nor yarn pnpify lessc … makes any difference

  3. dosubot commented on Sep 17, 2025

    @dosubot

    This happens because Less's plugin loader uses Node's standard require logic to load plugins, which doesn't work with Yarn PnP's virtual module resolution. Neither running lessc via yarn nor pnpify can fix this, since the loader doesn't support PnP or provide hooks for custom resolution—it's hardcoded to expect node_modules and direct require calls (plugin-loader.js reference).

    Workarounds are limited: you could patch or monkey-patch the plugin loader to use Yarn's PnP API, or run Less in a classic node_modules environment. There's no official or documented solution for PnP support in Less at this time. If PnP compatibility is critical for your workflow, you may want to consider raising a feature request.

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about less.js Share Dosu with your team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions