【问题标题】:ng command is working in vs code PowerShell not in vs code git bashng 命令在 vs code PowerShell 中有效,在 vs code git bash 中无效
【发布时间】:2022-12-21 09:55:32
【问题描述】:

angular CLI 命令在 vs code git bash 中不起作用,而它在 Powershell 中起作用。 错误如下:- C:\Users\amitk\AppData\Roaming\npm/node_modules/node/bin/node: 第 1 行:This: command not found

【问题讨论】:

    标签: angular bash visual-studio powershell visual-studio-code


    【解决方案1】:

    请检查环境变量中路径变量的值。看起来它无法从您的 git bash 环境中的路径中找到节点命令。有时在您的 Windows 中,该节点指向 Windows 节点文件夹。

    在 Powershell 中,请运行以下命令以确定它正在使用哪个节点位置 where node

    在你的 git bash 中检查路径是否包含包含节点命令的目录。

    【讨论】:

    • 要在 PowerShell 中查找命令,请使用 Get-Command。或者,使用where.exe,但您必须调用它.exe,因为 where 是不相关的 Where-Object cmdlet 的内置 PowerShell 别名。
    【解决方案2】:

    我知道有点晚了,但也许它会帮助其他人。

    你必须在 git bash 中设置别名 ng 之后它才会工作。

    首先本地化 C:/Users/Username/AppData/Roaming/npm/ng.cmd 中的 ng.cmd 文件 转到你的 git bash 并输入:

    alias ng='C:/Users/Username/AppData/Roaming/npm/ng.cmd'
    

    之后它会识别你的命令。

    要在 git bash 中永久设置别名 ng,您必须在 C:/Program Files/Git/etc/profile.d/aliases.sh 中编辑 aliases.sh 文件

    只需将别名语法添加到其他语法即可。

    希望这可以帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-05
      • 1970-01-01
      • 1970-01-01
      • 2020-03-24
      • 2020-10-03
      • 1970-01-01
      • 2021-03-26
      • 1970-01-01
      相关资源
      最近更新 更多