Skip to content

PNPM doesn't install peerDependencies correctly and consistenly. in this case @typescript-eslint/eslint-plugin #5319

@bryanprimus

Description

@bryanprimus

Based on this issue that i created #5231

Turns out the issue wasn't on vercel. it's pnpm that didn't consistent when installing dependencies.

We can reproduce it with this repo.

note: I have set up auto-install-peers=true in .npmrc

Steps to reproduce.

  • git clone https://github.com/bryantobing12/next-boilerplate
  • cd next-boilerplate
  • pnpm install
  • pnpm lint,
  • the error shows up that tells
    Failed to load plugin '@typescript-eslint' declared in '.eslintrc.json » eslint-config-airbnb-typescript » C:\Users\bryan\myfiles\sandbox\hzn-workspace\next-boilerplate\node_modules\.pnpm\eslint-config-airbnb-typescript@17.0.0_xo3iu7jah6intte3rsuo37bj74\node_modules\eslint-config-airbnb-typescript\lib\shared.js': Cannot find module '@typescript-eslint/eslint-plugin'
  • at this point if we inspect node_modules. it's indeed @typescript-eslint/eslint-plugin not installed.

image

and it makes sense the errors show up because it is not added to node_modules where it is supposed to be added since it's listed as peerDependencies in eslint-config-airbnb-typescript package

image.

  • next, rm -rf pnpm-lock.yaml && pnpm install
  • pnpm lint the error didn't show up.
  • and if we inspect node_modules

@typescript-eslint/eslint-plugin finally added there
image

why is this behavior happen? I don't want to always remove pnpm-lock.yaml before installing dependencies and It will create inconsistencies throughout the team

Originally posted by @bryantobing12 in #5231 (comment)

Additional Context

OS: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions