Deduplication tool for pnpm-lock.yaml files

Overview

pnpm-deduplicate

Remove duplicate dependencies from pnpm-lock.yaml.

This project is simple and not have many features. I see it as a temporary solution until we have built-in pnpm deduple command. Pull requests are welcome!

Install

pnpm install -g pnpm-deduplicate

Usage

Remove duplicates

Go to your project's root directory and run the following command to remove duplicate dependencies:

pnpm-deduplicate

List duplicates

If you only want to list duplicates instead of update pnpm-lock.yaml, run:

pnpm-deduplicate --list

You will get a list of duplicates like this:

Package "@babel/core" wants ^7.17.10 and could get 7.18.2, but got 7.18.0
Package "@babel/core" wants ^7.15.5 and could get 7.18.2, but got 7.18.0
Package "@babel/core" wants ^7.7.5 and could get 7.18.2, but got 7.18.0
Package "@babel/generator" wants ^7.7.2 and could get 7.18.2, but got 7.18.0
Package "@babel/generator" wants ^7.18.0 and could get 7.18.2, but got 7.18.0

Solutions for other package managers

For Yarn v1, you can use yarn-deduplicate.

For Yarn v2 or greater version, you can use the built-in yarn dedupe command.

For NPM, you can use the built-in npm dedupe command.

License

MIT

Comments
  • Error exit code when using --list

    Error exit code when using --list

    First of all thanks for this script.

    I'd like to have an error exit code to add a check on the ci

    For example when running: pnpm exec pnpm-deduplicate --list

    image

    Rather than zero have an error code = 1 (for example), That way it's easy to add a github action

          - name: 🔎 Check for duplicates
            run: |
              pnpm exec pnpm-deduplicate --list
    
    opened by belgattitude 2
  • Support `use-inline-specifiers-lockfile-format` config option introduced in pnpm v7.7.0

    Support `use-inline-specifiers-lockfile-format` config option introduced in pnpm v7.7.0

    First of all, amazing tool ;)

    I have used it a couple of days ago and it worked just fine.

    In the mean time, we have opted-in to the new use-inline-specifiers-lockfile-format config option: https://github.com/pnpm/pnpm/releases/tag/v7.7.0

    When I run npx pnpm-deduplicate now, it ends up breaking with:

    /home/<user>/.npm/_npx/08ff248d84e117fb/node_modules/dependency-path/lib/index.js:72
        if (reference.startsWith('link:')) {
                      ^
    
    TypeError: reference.startsWith is not a function
        at Object.refToRelative (/home/<user>/.npm/_npx/08ff248d84e117fb/node_modules/dependency-path/lib/index.js:72:19)
        at /home/<user>/.npm/_npx/08ff248d84e117fb/node_modules/@pnpm/lockfile-walker/lib/index.js:62:32
        at Array.forEach (<anonymous>)
        at /home/<user>/.npm/_npx/08ff248d84e117fb/node_modules/@pnpm/lockfile-walker/lib/index.js:61:14
        at Array.forEach (<anonymous>)
        at lockfileWalker (/home/<user>/.npm/_npx/08ff248d84e117fb/node_modules/@pnpm/lockfile-walker/lib/index.js:54:17)
        at file:///home/<user>/.npm/_npx/08ff248d84e117fb/node_modules/pnpm-deduplicate/dist/cli.mjs:81:112
        at Array.map (<anonymous>)
        at getAllDependencies (file:///home/<user>/.npm/_npx/08ff248d84e117fb/node_modules/pnpm-deduplicate/dist/cli.mjs:81:56)
        at async findDuplicatePackages (file:///home/<user>/.npm/_npx/08ff248d84e117fb/node_modules/pnpm-deduplicate/dist/cli.mjs:103:20)
    
    opened by mcmxcdev 2
  • pnpm-deduplicate doesn't work on node.js v18

    pnpm-deduplicate doesn't work on node.js v18

    $ node --version 
    v18.6.0
    $ pnpm-deduplicate --help
    Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './src/equals.js' is not defined by "exports" in /private/tmp/test-pnpm-deduplicate/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/ramda/package.json
    

    Caused by this issue: https://github.com/ramda/ramda/issues/3281

    opened by ocavue 2
  • package extensions overrided by pnpm-deduplicate

    package extensions overrided by pnpm-deduplicate

    It seems like dependencies that are added in the packageExtensions in package.json are being overrided when this package is run. It feels like this package should be taking the packageExtensions into account and not overriding those.

    opened by sahitpen1 2
  • chore(master): release 0.4.1

    chore(master): release 0.4.1

    opened by github-actions[bot] 1
  • Link to the GitHub in package.json

    Link to the GitHub in package.json

    Hi, I just discovered this through https://github.com/pnpm/pnpm/discussions/4143 - great tool! Thanks for making it!

    https://www.npmjs.com/package/pnpm-deduplicate doesn't have a link to this GitHub repo though. It's because there's no package.json repository field. Would you mind me sending a PR to add it in?

    opened by JoshuaKGoldberg 1
Releases(v0.4.1)
Owner
null
Detect npm packages by author name in your package-lock.json or yarn.lock.

detect-package-by-author Detect npm packages by author name in your package-lock.json or yarn.lock. Install Install with npm: # Not Yet Publish # npm

azu 2 Jan 11, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till mÀnniskor pÄ flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
An Obsidian plugin to grab all yaml fields from all files into a dataframe

Metadataframe Metadataframe allows you to get all metadata from your vault into CSV file. With CSV in-hand, you can do any data analysis you want with

null 7 Sep 15, 2022
A custom action for setting GitHub Workflow environment variables with YAML configuration files.

yaml-env-action - A custom action for setting GitHub Workflow environment variables with YAML configuration files. Introduction yaml-env-action is a c

Piper Dougherty 3 Dec 13, 2022
A high-resolution local database that uses precise algorithms to easily record data in local files within a project with persistent JSON and YAML support designed to be easy to set up and use

About A high-resolution local database that uses precise algorithms to easily record data in local files within a project with persistent JSON and YML

Shuruhatik 5 Dec 28, 2022
Vite plugin to client bundle i18next locales composited from one to many json/yaml files from one to many libraries. Zero config HMR support included.

vite-plugin-i18next-loader yarn add -D vite-plugin-i18next-loader Vite plugin to client bundle i18next locales composited from one to many json/yaml f

AlienFast 4 Nov 30, 2022
Get packages from a monorepo (pnpm, yarn, npm, lerna)

?? You can help the author become a full-time open-source maintainer by sponsoring him on GitHub. @egoist/get-packages Get packages from a monorepo (p

EGOIST 45 Jun 1, 2022
Detects which package manager (bun, pnpm, yarn, npm) is used.

@skarab/detect-package-manager Detects which package manager (bun, pnpm, yarn, npm) is used based on the current working directory. Features Support p

null 5 Sep 3, 2022
Turborepo starter with pnpm

Turborepo starter with pnpm This is an official starter turborepo. What's inside? This turborepo uses pnpm as a packages manager. It includes the foll

Jack Herrington 23 Dec 18, 2022
Remix TypeScript monorepo with Turborepo pipelines, Prisma, PostgreSQL, Docker deploy to Fly.io, pnpm, TailwindCSS and Tsyringe for DI.

Remix template with Turborepo, TypeScript and pnpm. The remix app deploys to fly.io or build to Docker image. Example packages for Database with prisma, Tsyringe dependency injection, UI, and internal TypeScript packages.

Philippe L'ATTENTION 33 Dec 29, 2022
Nuxt.js 3 x Histoire x Vitest x VitePress x Turbo (pnpm)

Turborepo nuxt starter This is a monorepo with Nuxt, Histoire, Vitest & VitePress as a starter for any project that can be easily extended. You can al

Gurvan 19 Dec 19, 2022
Vesting contract with multiple beneficiaries, tokens, and lock schedules.

⚠ This code has not been audited, use at your own risk Vesting Contract This contract handles the vesting of ERC20 tokens for multiple beneficiaries.

DeFi Wonderland 5 Mar 14, 2022
Provides Lock and RwLock synchronization primitives.

Lock Provides Lock and RWLock (read write lock) synchronization primitives for protecting in-memory state across multiple tasks and/or microtasks. Ins

Rocicorp 4 Apr 27, 2022
Deno's first lightweight, secure distributed lock manager utilizing the Redlock algorithm

Deno-Redlock Description This is an implementation of the Redlock algorithm in Deno. It is a secure, lightweight solution to control resource access i

OSLabs Beta 223 Dec 31, 2022
A pointer lock movement manager for customizing your own creative UI.

Pointer Lock Movement A pointer lock movement manager for customizing your own creative UI. Inspired by Figma's number input element: Dragging on an i

Zheeeng 8 Nov 4, 2022
A simple lock-and-release eventually-consistent DB to be consumed by multi-threaded applications in node.

worsen - a persistence store for quick prototyping A simple lock-and-release eventually-consistent DB to be consumed by multi-threaded applications in

Aniket Biprojit Chowdhury 2 Oct 1, 2022
⚡ It is a simplified database module with multiple functions that you can use simultaneously with sqlite, yaml, firebase and json.

Prisma Database Developed with ?? by Roxza ⚡ An easy, open source database ?? Installation npm i prisma.db --save yarn add prisma.db ?? Importing impo

Roxza 21 Jan 3, 2023