2

I have done customization in a npm package inside node_modules folder. Now I want to deploy it on heroku. But what heroku does is It will see the package.json and install the fresh package.

So someone suggested me to provide the custom url for a npm package, So that Heroku will download the npm package from this custom url not from npm.

How can I achieve the same?

Rajat
  • 486
  • 1
  • 10
  • 35
  • Possible duplicate of [npm install private github repositories by dependency in package.json](https://stackoverflow.com/questions/23210437/npm-install-private-github-repositories-by-dependency-in-package-json) – Amadan Apr 11 '19 at 05:54

1 Answers1

3

You should fork this package, make customization on your fork and install your version as a project dependency npm install <git repo url>

  1. find package that you want to customise on github
  2. use fork button to fork it to your repositories
  3. make customization on this new repo created in step 2
  4. run npm install with url address to your repository
Łukasz Szewczak
  • 1,851
  • 1
  • 13
  • 14
  • Thanks for quick response. Can you please provide a step by step reference for that? – Rajat Apr 11 '19 at 06:02
  • That's great. I will check and let you know. Thanks again. – Rajat Apr 11 '19 at 06:20
  • I have forked library and use git clone to copy the forked repo at my computer and done the customizations. –  Apr 11 '19 at 06:48
  • Please let me know, what should I do next? –  Apr 11 '19 at 06:48
  • push changes to your repo, and then use your repo url during npm install – Łukasz Szewczak Apr 11 '19 at 06:56
  • I pushed my changes to repo. Below is my repo url: https://github.com/rajatlnweb/drupal-nodejs – Rajat Apr 11 '19 at 07:09
  • My npm module name is drupal-node.js. Can you please tell me "How can i specify the repo url inside package.json? – Rajat Apr 11 '19 at 07:09
  • run `npm install https://github.com/rajatlnweb/drupal-nodejs.git`, and in `package.json` ther wiil be `"drupal-node.js": "git+https://github.com/rajatlnweb/drupal-nodejs.git"` – Łukasz Szewczak Apr 11 '19 at 07:17
  • Should I need to run "npm install https://github.com/rajatlnweb/drupal-nodejs.git" on server root? As I am using so many dependencies in my project. – Rajat Apr 11 '19 at 07:23
  • can't I specify the "drupal-node.js" : "git+https://github.com/rajatlnweb/drupal-nodejs.git" directly in package.json and run npm install directly at server root? – Rajat Apr 11 '19 at 07:25
  • I am getting error: " Could not install from "git+github.com\rajatlnweb\drupal-nodejs.git" as it does not contain a package.json file". – Rajat Apr 11 '19 at 07:29
  • I do not understand what you mean by the end. Yes you can put this directly in packae.json and then after running npm install, every dependencies will be downloaded – Łukasz Szewczak Apr 11 '19 at 07:29
  • okay, Trying it. Will let you know if got any error in 2 minutes. – Rajat Apr 11 '19 at 07:32
  • Sir, I created a new package.json file and in dependencies I placed "drupal-node.js" : "git+https://github.com/rajatlnweb/drupal-nodejs.git" – Rajat Apr 11 '19 at 07:36
  • And when I hit "npm install". It's giving error "couldn't install from repo as it doesn't contain a package.json file" – Rajat Apr 11 '19 at 07:37
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/191637/discussion-between-lukasz-szewczak-and-rajat). – Łukasz Szewczak Apr 11 '19 at 07:37