I have searched this topic for long time, currently all the solutions and examples work in git, but no direct solution for Mercurial.
Working example taken from somewhere similar links.
"private": true
to your package.json
Then to reference private npm module in package.json
{
"name": "myapp",
"dependencies": {
"private-repo": "git+ssh://[email protected]:myaccount/myprivate.git#v1.0.0",
}
}
As I read from official npm page this all works only with git https://docs.npmjs.com/files/package.json#git-urls-as-dependencies
So how to do the same thing in Mercurial or currently it's seems to be possible only with Git ?
Peer Dependencies: In package. json file, there is an object called as peerDependencies and it consists of all the packages that are exactly required in the project or to the person who is downloading and the version numbers should also be the same. That is the reason they were named as peerDependencies.
How do I add a Git repo to a NPM package? To npm install a public project that is hosted on Github, and not the NPM registry, add the Github repo to package. json dependencies using the username/repo#branch-name format. Run npm install and npm will download the project and save it into your /node_modules/ folder.
If you're not publishing your project to the NPM registry or otherwise making it publicly available to others, your package. json is still essential to the development flow. Your project also must include a package. json before any packages can be installed from NPM.
If you are using Bitbucket to host your project's Mercurial repo, it does provide links to download snapshots of your project as a tar.gz file. These URLs are actually usable in package.json
dependencies.
For example, my pagedown
project's download page has a link to this URL for a gzipped snapshot of the latest default
branch changes:
https://bitbucket.org/ncraike/pagedown/get/default.tar.gz
so in another project's package.json
, I can specify:
"dependencies": {
"pagedown": "https://bitbucket.org/ncraike/pagedown/get/default.tar.gz"
}
npm handles this fine when I do an npm install
from the dependent package, installing it correctly to the node_modules
subdirectory.
This isn't a general solution for Mercurial repositories (and I agree it'd be nice if npm accepted Mercurial URLs as well) but this could be a reasonable workaround if you're using Bitbucket or a similar site for hosting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With