【问题标题】:Git Bash npm package commands not found未找到 Git Bash npm 包命令
【发布时间】:2020-09-22 08:40:34
【问题描述】:

我最近在 Git Bash 上通过 npm 全局安装了 Vue-cli。然而,当我运行vue 时,我得到C:\Users\[User]\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found。我不是 bash 专家,但我很确定 PATH 设置不正确。但是如果我运行env|grep PATH,我可以在我的路径中看到C:\Users\[User]\AppData\Roaming\npm

但是,如果我在基本 cmd 上运行 vue,它会按预期工作。我的 git bash 是否缺少某些东西?另外,如果我运行npm config get prefix,我会得到C:\Users\[User]\AppData\Roaming\npm

请注意,我以 Vue 为例。运行create-react-app 时出现同样的错误。

我有最新版本的 git bash (2.28.0) 和 Windows 10。

【问题讨论】:

    标签: bash git npm


    【解决方案1】:

    git 安装的终端模拟器名为 Mintty。要使用 Mintty 运行 npm,您需要将路径添加到环境变量。

    将以下行添加到您的 ~.bash_profile 文件中。如果不存在,则创建它 当 Mintty 启动时,它将读取 .bash_profile。你现在应该可以运行 npm 这些其他问题也可能会有所帮助。

    https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-pathhttps://askubuntu.com/questions/58814/how-do-i-add-environment-variables

    【讨论】:

    • 对不起,我对终端不太熟悉。我应该在我的 .bash_profile 中添加哪一行?
    • 另外,我无法保存 bash_profile(在 vim 上编辑)。它说无法打开文件进行写入。我必须对其进行 chmod 吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-19
    • 2022-01-19
    • 2019-06-26
    • 1970-01-01
    • 2018-05-21
    相关资源
    最近更新 更多