npm 从本地位置而不是从网络安装软件包? [英] npm to install packages from local position rather than from web?

查看:43
本文介绍了npm 从本地位置而不是从网络安装软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题让我抓狂,npm 数据库里有一个包,但是有一些bug,已经在github 中修复了,我如何使用修复版本(github 版本)?

The problem drove me crazy, there is a package in npm database, but it has some bugs, which are already fixed in github, how could I make use of the fixed version(github version)?

推荐答案

您可以直接从 GitHub 存储库安装,甚至只需使用 GitHub 用户名和存储库名称:

You can install directly from the GitHub repository, even just using the GitHub username and the repository name:

npm install LearnBoost/socket.io

您还可以添加;,指定例如提交哈希或版本标签,如下所示:

You can also add a <commit-ish>, specifying e.g. a commit hash or a version tag, like so:

npm install LearnBoost/socket.io#1.7.x

如果没有协议,这将被解释为 git://github.com/LearnBoost/socket.io.您还可以分别使用 gitlab:gist:bitbucket: 作为 repo 前缀.有关更多信息,请参阅使用 git URL 作为依赖项.

Without a protocol, this will be interpreted as git://github.com/LearnBoost/socket.io. You can also prefix the repo with gitlab:, gist: or bitbucket:, respectively. For more information, see Using git URLs as dependencies.

您可以直接从 URL 安装,例如:

You can install directly from a URL, example:

npm install https://github.com/LearnBoost/socket.io/tarball/master

您可以在任何项目页面的下载"下找到 Github 上的 URL.选择下载为 tar.gz"链接.

You can find the URL on Github under "Downloads" on any project page. Select the "Download as tar.gz" link.

或者你可以安装一个压缩包:

Or you can install a tarball:

npm install foo.tar.gz

请参阅npm install(1).

我应该提到这在 package.json 文件中同样有效.在依赖项中指定 URL 而不是版本,如下所示:

I should mention that this works equally well in package.json files. Specify the URL instead of the version in your dependencies, like so:

...
"dependencies": {
  "foo": "http://example.com/foo.tar.gz",
  "bar": "1.2.x",
  ...
}

这篇关于npm 从本地位置而不是从网络安装软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆