DEV Community

Shivang Chauhan
Shivang Chauhan

Posted on • Updated on

Edit npm package and persist the changes on npm install

Have you ever wondered how you can edit any npm package and have those changes persist if npm i gets run?

You can use patch-package to do this, all you need to do is follow these steps -

  • Make changes to the npm package.
  • After making changes to the npm run this command npx patch-package (package name).
  • This command will create a patches folder inside your project directory and that directory will hold all the changes which you did to the npm package.
  • Now whenever you do npm i it will install the packages, to get those changes which you did in the npm package just run this command npx patch-package to apply the changes.

Now you are done, all your changes will be applied.

Making this process automatic

Just add the command as postinstall like this in package.json file -

"postinstall": "npx patch-package"

Check out more:

What is AWS Artifact?

How to extract text from an image using AWS Step Functions and Serverless

Image Recognition using AWS Serverless

Understand Math functions in Javascript

DynamoDB VS MongoDB

Top comments (0)