【问题标题】:Defining paths in .bash_profile在 .bash_profile 中定义路径
【发布时间】:2012-04-22 16:57:30
【问题描述】:

我最近一直在安装几个 Node.js 模块/应用程序,以便能够开始一个新的 Web 项目。我使用 NPM 安装模块,但每次遇到同样的问题:模块无法全局访问。

我没有在一本安装手册中阅读过任何有关更改/添加到 .bash_profile 的内容,但我通过一些教程发现这是必要的。

我已经设法让一些模块以这种方式工作,但不是每个人,我真的可以在这里得到一些帮助。我遇到的最后一个安装问题是 Expresso。我应该在 .bash_profile 中输入什么才能全局访问它?

可执行的 Expresso 文件位于以下文件夹中: /Users/toby/node/imapp/imagebridge/node_modules/expresso/bin/expresso

以下内容不起作用: export PATH="/Users/toby/node/imapp/imagebridge/node_modules/expresso/bin/expresso/:$PATH"

【问题讨论】:

  • 你重启你的shell了吗?你应该工作的方式。

标签: bash node.js path .bash-profile


【解决方案1】:

从路径中移除 espresso,例如

export PATH="/Users/toby/node/imapp/imagebridge/node_modules/expresso/bin/:$PATH"

因为 espresso 很可能是可执行文件。路径是搜索可执行文件的目录列表,而不是可执行文件列表。

【讨论】:

    【解决方案2】:

    这也是捆绑模块的一个很好的补充:

    export PATH="./node_modules/.bin:$PATH"
    

    它允许您从当前工作目录的node_modules 子目录运行二进制文件

    【讨论】:

      猜你喜欢
      • 2013-10-14
      • 2015-12-26
      • 1970-01-01
      • 2014-09-03
      • 2018-10-26
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 2021-01-10
      相关资源
      最近更新 更多