
Then you can point the user project at the new tag, and you are good to go.
#Npm install from github example code
Now you can iterate on your first module, and when there are new features or fixes, increment package.json version (I suggest using next-ver to compute the next version based on commit messages), tag the commit and push the code and tag to GitHub. Now the build should be able to access clone NPM package from the private repository into this project. Go to the project's Settings / Checkout SSH keys and click the button twice. Thus the same key cannot be used to clone another private repository. When Circle connects the new project to the GitHub repository it created an SSH key restricted to that repository. Npm ERR! A complete log of this run can be found in: Npm ERR! /usr/bin/git ls-remote -h -t git:///bahmutov/private-module-example.git > node -e "console.log(require('private-module-example'))" "test": "node -e \"console.log(require('private-module-example'))\"" If the module has not been installed, the npm test would crash and burn. v1-dependencies-Īnd my test script will just load the private-module-example module. I will set up continuous integration (CI) server to run "tests" on CircleCI. Great, but does it work? Let's open Node and load the dependency 1 "private-module-example": "github:bahmutov/private-module-example#1.0.0" My package.json reflects the installed dependency package.json 1
#Npm install from github example install
$ npm install -S bahmutov/private-module-example#1.0.0Īdded 1 package from 1 contributor and audited 1 package in 6.961s Only instead of the package name, I can specify GitHub username and repository name, instead of the version, I can specify a commit SHA or a tag. The install command looks almost the same as "standard" npm i. "description": "Private repo that uses another private repo as an NPM module", I have created another private GitHub repository bahmutov/private-module-example-user - this repo will install the code from the first repository without going to NPM. Great, I have 1 release in my private GitHub repository. Then I created a tag (same as version) and pushed it too 1 "test": "echo \"Error: no test specified\" & exit 1" "description": "Private module installation example", The package.json sets the private: true to avoid accidentally publishing this package to the NPM registry. I can load this module locally from the project's root folder 1 1Ĭonsole.log( 'this module will export stuff from "foo"') It contains a small JavaScript export just for show. I made a private repository bahmutov/private-module-example on GitHub. Why bother if it might not work out? Here is how you can quickly push code to a private GitHub repository yet make it available to other projects. Maybe you are just experimenting, and setting things up takes effort. Let's say you have some JavaScript code you want to share among several projects, but you don't want to create a private NPM package yet.
