简体   繁体   中英

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 !

You can use forked repo to install the package.

like :

npm install github_url_of_your_repo

For more details:

See this .

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"
  },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM