Skip to content

Not working with yarn 3.6.3 in pnp mode #1319

Open
@mauro-ni

Description

Description

In a project using yarn 3.6.3 in pnp mode, I'm not able to use husky + lint-staged as pre-commit hook.

My .yarnrc.yml file:

plugins:
  - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
    spec: "@yarnpkg/plugin-interactive-tools"

pnpEnableEsmLoader: true

yarnPath: .yarn/releases/yarn-3.6.3.cjs

Relevant section in package.json

...

"scripts": {
   ...
    "postinstall": "husky install"
  },
"lint-staged": {
    "*.{js,jsx}": [
      "eslint --fix",
      "prettier --write"
    ],
    "*": "prettier --ignore-unknown  --write"
  },

...

Steps to reproduce

Create an application based on yarn 3 + pnp mode, add lint-staged, configure it and then run

yarn run lint-staged

Debug Logs

expand to view
[PATH TO MY APP]/.yarn/cache/lint-staged-npm-14.0.1-50e37043be-8c5d740cb3.zip/node_modules/lint-staged/lib/loadConfig.js:4
import { lilconfig } from 'lilconfig'
         ^^^^^^^^^
SyntaxError: Named export 'lilconfig' not found. The requested module 'lilconfig' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'lilconfig';
const { lilconfig } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:122:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:188:5)
    at async CustomizedModuleLoader.import (node:internal/modules/esm/loader:228:24)
    at async loadESM (node:internal/process/esm_loader:40:7)
    at async handleMainPromise (node:internal/modules/run_main:66:12)

Node.js v20.5.1

Environment

  • OS: macOS Ventura 13.5.1
  • Node.js: 20.5.1
  • lint-staged: 14.0.1

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions