Vivien Adnot
Vivien Adnot

Reputation: 1257

How can I use a custom version of a npm package in my project?

I use Primus in my project. Primus is a wrapper for websockets libraries like sockjs, which I use.

At server boot, primus creates a script, that will then be downloaded by our client, as the client part of the socket. This script embeds the source code of sockjs. Problem, it uses the 1.1.2 version of sockjs, that contains a bug, fixed in version 1.1.4, but not in Primus yet.

I asked the maintainers of Primus to change it but the are too slow to do it. So I forked Primus, and I replaced the wrong file by the good one.

Now, I want to use this package instead of the wrong one, declared currently in my package.json.

I don't know what the good practice is in this case, the only solution I can think is to npm-publish my modified package under a different name, like amplement-primus, and then do npm install --save amplement-primus to insert it in my project. I have no idea of it breaks a rule of npm.

Do you think it's a good idea, or do you have something better in mind ? Thank you !

Upvotes: 1

Views: 2176

Answers (2)

Vivien Adnot
Vivien Adnot

Reputation: 1257

I used the github url of the project to reference it in package.json:

  "dependencies": {
    "primus": "git+https://github.com/amplement/primus.git",
    "sockjs": "^0.3.19"
  },

Upvotes: 2

Harshal Yeole
Harshal Yeole

Reputation: 4983

You can use forked repo to install the package.

like :

npm install github_url_of_your_repo

For more details:

See this.

Upvotes: 1

Related Questions