Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM install from github using a tag

I need to do a npm install into my angular2 project from git but using a tag which is tag = 6.0.0.

e.g.

git [email protected]:akveo/ng2-smart-table.git
cd ng2-smart-table
git checkout tags/v0.6.0-0

How would I do the equivalent of :

  npm install --save PACKAGE_NAME




npm install [email protected]:akveo/ng2-smart-table.git#v0.6.0-0 
npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/Cellar/node/6.5.0/bin/node" "/usr/local/bin/npm" "install" "[email protected]:akveo/ng2-smart-table.git#v0.6.0-0"
npm ERR! node v7.0.0
npm ERR! npm  v3.10.8

npm ERR! Unsupported URL Type: github.com:akveo/ng2-smart-table.git#v0.6.0-0
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
like image 474
Tampa Avatar asked Apr 06 '17 10:04

Tampa


People also ask

How do I install directly from GitHub?

From the GitHub Apps settings page, select your app. In the left sidebar, click Install App. Click Install next to the organization or personal account containing the correct repository. Install the app on all repositories or select repositories.

Does npm download from GitHub?

The npm installation from GitHub is quite useful for testing packages. It also gives the flexibility to install any specific branch, version, tag, and so on.

Can you tag a GitHub repo?

Yes, we can add tags directly to GitHub. To sync the same with your local repository, you need to pull the changes using Git.


2 Answers

NPM allows installation using commit-ish tags on GitHub:

npm install <git remote url>

for example:

npm install git+ssh://[email protected]:npm/npm.git#v1.0.27
npm install git+https://[email protected]/npm/npm.git
npm install git://github.com/npm/npm.git#v1.0.27

Note that you need to specify the protocol in the url, e.g. git+https://.

Documentation: https://docs.npmjs.com/cli/install

like image 188
paradite Avatar answered Oct 22 '22 03:10

paradite


Another option from the npm docs:

As of version 1.1.65, you can refer to GitHub urls as just "foo": "user/foo-project". Just as with git URLs, a commit-ish suffix can be included.

These 2 commands install the same tag v0.6.0-0 of the akveo/ng2-smart-table github repo (tested npm version 5.4.2)

npm install akveo/ng2-smart-table#v0.6.0-0

npm install github:akveo/ng2-smart-table#v0.6.0-0

like image 41
Thomas Vanier Avatar answered Oct 22 '22 03:10

Thomas Vanier