0

My application uses one npm package (Say x package). I made few changes in one file of x package.

So now i need to manually send that file to other developer's so that they can replace the file of X package. i.e Every time npm install X package get executed on new system, they need to replace that file.

I tried to reach the developer of that npm X package & created pull request but no luck so far.

Query: So do i need to create my one module around the X package or any other workaround. please suggest.

Yogesh Lolusare
  • 2,162
  • 1
  • 24
  • 35
  • assuming you are using some sort of source control for your project, you can just include the changed files in your commit? With an appropriate message to inform the team – Ryan Turnbull Sep 04 '17 at 10:24
  • 1
    If x package only depends on JS files then you can copy those JS files from node_modules/x_package folder and copy into your project src code folder, then import components from those files which you have copied, and also you can make changes in those files. – Paras Watts Sep 04 '17 at 10:35
  • 3
    You should create your own module by cloning it on github and changing some files after that link that directly in package.json so that every time npm install is done nothing will be changed. and see this link to install it https://stackoverflow.com/questions/17509669/how-to-install-an-npm-package-from-github-directly – Waqas Ahmed Sep 04 '17 at 10:38
  • @Paras thank you for your suggestion. – Yogesh Lolusare Sep 12 '17 at 12:24
  • @Waqas thank you for your suggestion. I think you should add this an answer. – Yogesh Lolusare Sep 12 '17 at 12:25
  • @Ryan your suggestion is the good workaround but need to manually handle the stuff. – Yogesh Lolusare Sep 12 '17 at 12:25

2 Answers2

1

In this situation, if you've issued a pull request, you already have a fork of the package's repo, so you have a few options. If you're not sure why your PR isn't being accepted, its probably worth finding out, as that involves the least work for you. Your options:

  1. There are patch managing packages, such as patch-package which are designed to deal with this situation, YMMV depending on your build chain

  2. You could just publish your version to npm, using a name that indicates its a variation of the package, and manage it until your PR is accepted. If you have a private package manager, this might be easiest.

  3. Get your collaborators to use the version of the package you forked (checked out as source), and use something like yalc to install it locally until your PR is accepted. You can use npm link for this, but yarn doesn't handle linking well

Nick
  • 1,822
  • 10
  • 9
1

You should create your own module by cloning it on github and change files that you want and commit them. After that link that repository directly in package.json so that every time npm install is done nothing will be changed. Follow this to link in package.json How to install an npm package from GitHub directly?

Waqas Ahmed
  • 1,321
  • 1
  • 14
  • 23