2017-04-06 74 views
0

我需要从git中使用标记= tag = 6.0.0来从我的angular2项目执行npm install。使用标记从github安装NPM

例如

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

我会怎么做等价的:

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: 

回答

6

NPM允许使用在GitHub上commit-ish标签安装:

npm install <git remote url>

例如:

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 

请注意,您需要在网址中指定协议,例如git+https://

文档:这里https://docs.npmjs.com/cli/install

+0

我添加了错误,当我想你的建议 – Tampa

+0

@Tampa你错过了协议,我用'npm install git + https://[email protected]:akveo/ng2-smart-table.git#v0.6.0-0'进行了测试,它工作正常。 – paradite

0

如上如何安装通过NPM的rpeo解释是一些额外的信息来完成上述anwser。

如果你不想担心该协议意味着你不想要的网址从原始地址变更就可以设定网址的格式如下重写:

git config --global url."https://".insteadOf git:// 
0

另一种选择从npm docs

从版本1.1.65开始,您可以参考GitHub网址为“foo”:“user/foo-project”。就像使用git URL一样,可以包含commit-ish后缀。

这两个命令安装相同的标签akveo/ng2-smart-table GitHub库的v0.6.0-0(NPM测试版5.4.2

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

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