window.pipedriveLeadboosterConfig = { base: 'leadbooster-chat.pipedrive.com', companyId: 11580370, playbookUuid: '22236db1-6d50-40c4-b48f-8b11262155be', version: 2, } ;(function () { var w = window if (w.LeadBooster) { console.warn('LeadBooster already exists') } else { w.LeadBooster = { q: [], on: function (n, h) { this.q.push({ t: 'o', n: n, h: h }) }, trigger: function (n) { this.q.push({ t: 't', n: n }) }, } } })() First aid for broken JavaScript dependencies - The Codest
The Codest
  • About us
  • Services
    • Software Development
      • Frontend Development
      • Backend Development
    • Staff Augmentation
      • Frontend Developers
      • Backend Developers
      • Data Engineers
      • Cloud Engineers
      • QA Engineers
      • Other
    • It Advisory
      • Audit & Consulting
  • Industries
    • Fintech & Banking
    • E-commerce
    • Adtech
    • Healthtech
    • Manufacturing
    • Logistics
    • Automotive
    • IOT
  • Value for
    • CEO
    • CTO
    • Delivery Manager
  • Our team
  • Case Studies
  • Know How
    • Blog
    • Meetups
    • Webinars
    • Resources
Careers Get in touch
  • About us
  • Services
    • Software Development
      • Frontend Development
      • Backend Development
    • Staff Augmentation
      • Frontend Developers
      • Backend Developers
      • Data Engineers
      • Cloud Engineers
      • QA Engineers
      • Other
    • It Advisory
      • Audit & Consulting
  • Value for
    • CEO
    • CTO
    • Delivery Manager
  • Our team
  • Case Studies
  • Know How
    • Blog
    • Meetups
    • Webinars
    • Resources
Careers Get in touch
Back arrow GO BACK
2018-12-27
Software Development

First aid for broken JavaScript dependencies

Daniel Grek

If you are a software developer, then you probably already know, that one of your many roles is definitely not to be yet another wheel inventor. At least, not in most of the cases.

I would like to write about JavaScript dependencies. But let’s start from the beginning. If you are a software developer, then you probably already know, that one of your many roles is definitely not to be yet another wheel inventor. At least, not in most of the cases. World has proceeded far enough to say that today there exist packages for almost everything, making our development easier and more efficient.

This of course is not an encouragement for losing interest in other issues – every package has quite a large space to improve and evolve. However, your business goal is to bring a complete product on a plate just on time or even before it is up. Packages will help you fulfill those plans, bringing npm or yarn on the top of your best friends’ list, but be aware: any solution, as well as this one, may also bring risk. And we will try to describe it and show you a better way of getting away with it in the article below.

Let’s start with a story…

Imagine a large JavaScript project. Business requirement obligates developers to use a specific package, allowing a proper integration with another system of a client. And that is completely fine. MVP has been brought on time, next contract has been signed and development is carried on. Client asks to integrate the next part of a system, which requires your package update.

This part goes well, until tests are fired. It seems that the package contains a simple, but inconvenient bug, that has not yet been fixed in any product release and it is known that this won’t happen soon enough. You cannot just fix your node_modules directory – it should be removed out from your repository from tracking, therefore your collaborators will never know anything about your changes! Well, while you were reading this, probably you have already understood what to do – fork. But do you really need such a hammer?

Understand your problem

You must be aware, if the problem you are facing with is going to involve just you or a larger community. Sometimes, people interpret lack of certain functionality as a bug, which is not always correct. Therefore, your solution may not be accepted by a community and not included into an official repository. However, you still need it here and now. Well, let’s patch it!

According to the release notes of github repository, patch-package ) was released officially in May 2017. It is a powerful tool, that allows modifications inside dependency project to be installed in your node_modules directory. Some may say that this is quite a madness – firing install command your dependence manager will overwrite the changes.

Well, this is correct. However, a patch-package coexists with npm and yarn perfectly (I must admit it works slightly better with npm so far, you can read more in “Why you should use postinstall-prepare with Yarn?” section of README file) and takes full advantage of a script preparation (“script”: { “prepare”:“”}) of your package.json file. Patch-package literally creates a diff directory between your changes and the original package, stored in the patch folder of your actual project.

After running install command and downloading all dependencies, it applies that difference to the project directory, making a perfect reconstruction of your changes for all collaborators. It makes your life simpler, doesn’t it? The solution has some disadvantages as well. The patch-package cannot fix dependencies of your package or make any changes in package.json.

In this case you may use the fork solution. Also, you must consider the number of changes you are about to apply into your dependency package and whether they will grow in time. In case the will – you should think carefully when using fork, as this is a project of your own.

Don’t be selfish!

Patching is a great way to fix your dependencies without creating endless forks and generating multiple project sources. But you should always remember, that taking advantage of community should not be a one-directional. If you find a bug or feel like you can improve the package you’re using, you should always consider helping others by registering an issue or even by contributing to the project!

Related articles

Software Development

Build Future-Proof Web Apps: Insights from The Codest’s Expert Team

Discover how The Codest excels in creating scalable, interactive web applications with cutting-edge technologies, delivering seamless user experiences across all platforms. Learn how our expertise drives digital transformation and business...

THECODEST
Software Development

Top 10 Latvia-Based Software Development Companies

Learn about Latvia's top software development companies and their innovative solutions in our latest article. Discover how these tech leaders can help elevate your business.

thecodest
Enterprise & Scaleups Solutions

Java Software Development Essentials: A Guide to Outsourcing Successfully

Explore this essential guide on successfully outsourcing Java software development to enhance efficiency, access expertise, and drive project success with The Codest.

thecodest
Software Development

The Ultimate Guide to Outsourcing in Poland

The surge in outsourcing in Poland is driven by economic, educational, and technological advancements, fostering IT growth and a business-friendly climate.

TheCodest
Enterprise & Scaleups Solutions

The Complete Guide to IT Audit Tools and Techniques

IT audits ensure secure, efficient, and compliant systems. Learn more about their importance by reading the full article.

The Codest
Jakub Jakubowicz CTO & Co-Founder

Subscribe to our knowledge base and stay up to date on the expertise from the IT sector.

    About us

    The Codest – International software development company with tech hubs in Poland.

    United Kingdom - Headquarters

    • Office 303B, 182-184 High Street North E6 2JA
      London, England

    Poland - Local Tech Hubs

    • Fabryczna Office Park, Aleja
      Pokoju 18, 31-564 Kraków
    • Brain Embassy, Konstruktorska
      11, 02-673 Warsaw, Poland

      The Codest

    • Home
    • About us
    • Services
    • Case Studies
    • Know How
    • Careers
    • Dictionary

      Services

    • It Advisory
    • Software Development
    • Backend Development
    • Frontend Development
    • Staff Augmentation
    • Backend Developers
    • Cloud Engineers
    • Data Engineers
    • Other
    • QA Engineers

      Resources

    • Facts and Myths about Cooperating with External Software Development Partner
    • From the USA to Europe: Why do American startups decide to relocate to Europe
    • Tech Offshore Development Hubs Comparison: Tech Offshore Europe (Poland), ASEAN (Philippines), Eurasia (Turkey)
    • What are the top CTOs and CIOs Challenges?
    • The Codest
    • The Codest
    • The Codest
    • Privacy policy
    • Website terms of use

    Copyright © 2025 by The Codest. All rights reserved.

    en_USEnglish
    de_DEGerman sv_SESwedish da_DKDanish nb_NONorwegian fiFinnish fr_FRFrench pl_PLPolish arArabic it_ITItalian jaJapanese ko_KRKorean es_ESSpanish nl_NLDutch etEstonian elGreek en_USEnglish