npm install 官网资料(git+https在packa

2021-07-26  本文已影响0人  浅浅_2d5a

来自官网https://www.npmjs.cn/cli/install/
npm install
别名
npm i
参数别名--save-dev 是 -D
This command installs a package, and any packages that it depends on.
npm install 会安装工程需要的包,并且会安装包的依赖包
If the package has a package-lock or shrinkwrap file, the installation of dependencies will be driven by that,with an npm-shrinkwrap.json taking precedence if both files exist.
如果有package-lock文件,会按照这个文件进行安装,如果两个文件都存在,则npm-shrinkwrap.json优先
(如果,更改package.json的地址,需要删除lock)
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.
从托管的git提供程序安装包,并用git克隆它。对于完整的git远程url,将只尝试该url。
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
<protocol> is one of git, git+ssh, git+http, git+https, or git+file
协议是 git, git+ssh, git+http, git+https, 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 the default branch of the repository is used.
如果提供了#<commit ish>,它将用于精确克隆该提交。如果commit ish的格式为#semver:<semver>,<semver>可以是任何有效的semver范围或确切版本,npm将在远程存储库中查找与该范围匹配的任何标记或引用,就像查找注册表依赖项一样。如果未指定#<commit ish>或#semver:<semver>,则使用存储库的默认分支。
Examples:
npm install git+ssh://git@github.com:npm/cli.git#v1.0.27
npm install git+ssh://git@github.com:npm/cli#semver:^5.0
npm install git+https://isaacs@github.com/npm/cli.git
npm install git://github.com/npm/cli.git#v1.0.27
GIT_SSH_COMMAND='ssh -i ~/.ssh/custom_ident' npm install git+ssh://git@github.com:npm/cli.git

验证过的:
gitLab的工程,作为包引入主工程,放在package.json中
"webgme-xxx": "git+https://gitlab.xxx.cn/hhhh.git",
通过npm install 可以成功安装
通过npm install webgme-xxx 可以成功安装
通过npm install git+https://gitlab.xxx.cn/hhhh.git 可以成功安装
使用cnpm install 不管加不加git+等,均报错

npm install git+ssh://git@github.com:npm/cli.git#v1.0.27
#v1.0.27可以是tag标签,可以是分支,默认分支master

git+https最为常用
ssh需要签名

git+的这种用法,在node_modules中包的package.json中有描述


image.png
上一篇 下一篇

猜你喜欢

热点阅读