鍍金池/ 問答/Linux  HTML/ npm 下載git 倉庫的代碼

npm 下載git 倉庫的代碼

今天看到npm的依賴可以配置git地址,想了解一下如果我配置的是git的地址,我通過npm下載下來的文件是哪些?怎么規(guī)定這些文件?還有如何指定分支或者tag?

回答
編輯回答
青黛色

就相當(dāng)于git clone下載的內(nèi)容。
路徑后邊加#指定branch/commit/tag

2017年4月25日 03:40
編輯回答
小曖昧

我覺得 npm install 文檔講的挺清楚的:

npm install <git remote url>:

Installs the package from the hosted git provider, cloning it with git. For a full git remote url, only that URL will be attempted.

<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
<protocol> is one of git, git+ssh, git+http, git+https, or git+file.

If #<commit-ish> is provided, it will be used to clone exactly that commit. If the commit-ish has the format #semver:<semver>, <semver> can be any valid semver range or exact version, and npm will look for any tags or refs matching that range in the remote repository, much as it would for a registry dependency. If neither #<commit-ish> or #semver:<semver> is specified, then master is used.

If the repository makes use of submodules, those submodules will be cloned as well.

If the package being installed contains a prepare script, its dependencies and devDependencies will be installed, and the prepare script will be run, before the package is packaged and installed.

The following git environment variables are recognized by npm and will be added to the environment when running git:

GIT_ASKPASS
GIT_EXEC_PATH
GIT_PROXY_COMMAND
GIT_SSH
GIT_SSH_COMMAND
GIT_SSL_CAINFO
GIT_SSL_NO_VERIFY
See the git man page for details.

Examples:

npm install git+ssh://git@github.com:npm/npm.git#v1.0.27
npm install git+ssh://git@github.com:npm/npm#semver:^5.0
npm install git+https://isaacs@github.com/npm/npm.git
npm install git://github.com/npm/npm.git#v1.0.27
GIT_SSH_COMMAND='ssh -i ~/.ssh/custom_ident' npm install
2017年2月5日 00:16