2017-04-06 102 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