【问题标题】:Some of the globally installed npm packages are not working一些全局安装的 npm 包不工作
【发布时间】:2021-05-16 20:07:56
【问题描述】:

我已在全局范围内安装了 npm,每当我运行 npm -v 以检查其版本时,它都会正确显示它,当前为 7.13.0

我还全局安装了 heroku-cli,但每当我运行 heroku --version 时,它都会显示:

C:\Users\MyName\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found

C:\Users\MyName\AppData\Roaming\npm 内部,我全局 都安装了heroku 和npm,但是每当我运行heroku 命令时,它都无法运行。我无法弄清楚这个问题。

下面我附上了我全局安装包目录的截图。

【问题讨论】:

    标签: javascript node.js npm mern heroku-cli


    【解决方案1】:

    也许你的 npm 的目录路径配置可能有一些错误。

    您可以按照以下步骤修改路径。

    1. 打开或创建 ~/.profile 文件并添加您的 npm 路径
    export PATH=C:\Users\MyName\AppData\Roaming\npm/node_modules/node/bin
    
    1. 在命令行上,更新您的系统变量:
    source ~/.profile
    

    否则,我建议更改 npm 官方文档中解释的 npm 的默认目录。(https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)。我也有类似的问题并遵循相同的说明。

    【讨论】:

    • 我有 windows 系统,并且在 npm 文档中它写的 注意:本节不适用于 Microsoft Windows。
    猜你喜欢
    • 1970-01-01
    • 2016-03-06
    • 2013-03-28
    • 2012-06-08
    • 2021-04-13
    • 2014-12-06
    • 2017-11-05
    • 2020-10-23
    • 1970-01-01
    相关资源
    最近更新 更多