【问题标题】:npm install single package from git repo not workingnpm 从 git repo 安装单个包不起作用
【发布时间】:2020-03-27 20:34:53
【问题描述】:

所以我的 package.json 中有这样的依赖项

"my-package": "git+https://urlToMyPackage/my-package.git#my-branch"

如果你执行“npm install my-package”,就会发生这种情况。

npm ERR! Linux 5.0.0-32-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "my-package"
npm ERR! node v6.11.0
npm ERR! npm  v3.10.10
npm ERR! code E404

npm ERR! 404 Not found : my-package
npm ERR! 404 
npm ERR! 404  'my-package' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/user/workdir/npm-debug.log

如果我执行“npm install”,它将从我的 git repo 连同所有其他软件包一起安装。似乎当您安装单个软件包时,它不会首先检查您的 package.json 以查看它是否不是从 npm 注册表安装的。

从以前可以工作的 git 主机安装单个包。现在有不同的 npm 命令来执行此操作吗?

【问题讨论】:

    标签: node.js git npm


    【解决方案1】:

    对于公共存储库

    "dependencies" : {
      "example" : "git://github.com/user/example.git#commit-ish"
    }
    

    如果您的存储库是私有的,那么首先从 Github 获取 oauth 令牌 Settings -> Applications -> Personal Access Token -> Generate new token

    "dependencies": {
    "example": "git+https://<token-from-github>:x-oauth-basic@github.com/<user>/<example>.git"
    }
    

    【讨论】:

    • 这不是托管在 GitHub 上的。为什么它搜索 npm 注册表而不是访问我的 URL。
    猜你喜欢
    • 1970-01-01
    • 2016-07-09
    • 1970-01-01
    • 1970-01-01
    • 2020-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-06
    相关资源
    最近更新 更多