【问题标题】:npm install git in VSCode在 VSCode 中安装 git
【发布时间】:2021-12-13 00:53:44
【问题描述】:

刚刚在 VSCode 终端中运行 npm install git 并运行 git --version 并得到以下响应:

git : The term 'git' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try 
again.
At line:1 char:1
+ git --version
+ ~~~
    + CategoryInfo          : ObjectNotFound: (git:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

安装 Node.js 和 git install 后已经重新启动。请帮助让 git 在 VSCode 中工作。

【问题讨论】:

  • 出于好奇:是什么让您认为npm install git 是安装 git 的正确方法?

标签: git npm visual-studio-code


【解决方案1】:

npm install git 不安装 git(即操作 git 存储库的命令行工具)。

它安装了npm package called git,这似乎是一个与 git 存储库交互的 JavaScript 库(这使得名称准确,但仍然具有误导性)。

npm 不是通用包管理器。

【讨论】:

    【解决方案2】:

    尝试使用 -g 安装 git global

    npm install -g git
    

    或者直接用官方文档安装 git https://git-scm.com/downloads

    【讨论】:

    • 这不会有太大帮助,因为 npm git 包实际上不是 git 命令行工具..
    【解决方案3】:
    1. Windows、macOS 和 Linux/Unix 安装:https://git-scm.com/downloads 并从您的下载文件夹运行安装程序。

    2. 在命令行中键入“git --version”,减去引号。

    这里是 Gits 网站上有关安装 Git 的其他文档:https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

    要使用命令行从 npm 安装 git,请使用“npm i git-win”减去引号。这里是 npm 从 npm 安装 git 的文档:https://www.npmjs.com/package/git-win

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-26
      • 1970-01-01
      • 2022-11-15
      • 1970-01-01
      • 2020-02-10
      • 1970-01-01
      • 1970-01-01
      • 2019-04-11
      相关资源
      最近更新 更多