2

I installed a package from npm, but I needed to customize it. The problem is that, when the team install or update npm packages, the customization is overwritten.

I would like to know if there is anyway to preserve this customization or if I need to upload another package with the customization...

2 Answers 2

3

as semanser says, you need fork the project, but the right way for include this in your package.json file is

"package-name": "<your user name>/<your package name>#<your branch>"

you can find additional information here

Sign up to request clarification or add additional context in comments.

1 Comment

Is it possible to install from Azure devops repository?
2
  1. Create a Github fork of a package that you need to customize.
  2. Make changes that you want in your fork (don't forget to commit and push them).
  3. Add the link to the fork to your package.json file in the following format:

    "dependencies": {
      "bar": "git://github.com/foo/bar.git"
    }
    
  4. (optional) Create a Pull Request and wait until your changes will be approved in the original repo.

7 Comments

I tried this, but it is not installing my package. :/
Connection timeout when trying to connect to github, I think it is something with the firewall, but I could clone the repo normally when tried locally, but, when I try npm install, it can't connect to github.
@FelipeAvelar maybe try another URL format, like mygithubuser/project or github:mygithubuser/project or git+https://[email protected]/mygithubuser/project.git or https://github.com/mygithubuser/project.git
When I tried git+https://[email protected]/mygithubuser/project.git, it executed npm install, but only get md files. :/
@FelipeAvelar Right, you are getting only .md files because your lib requires some build steps. Check out package.json of your installed lib, there is prepublish step, but it's not triggered in your case. For more details check also this link: stackoverflow.com/questions/40880642/… As documentation said, prepublish "Run BEFORE the package is packed and published, as well as on local npm install without any arguments." So to build lib you can trigger that event manually in your project.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.