【问题标题】:Issue with ~/.profile after fixing NPM permissions修复 NPM 权限后出现 ~/.profile 问题
【发布时间】:2017-06-01 14:47:57
【问题描述】:

在 OS X 上安装了 Node.js。通过更改 NPM 的默认目录(https://docs.npmjs.com/getting-started/fixing-npm-permissions 参见选项 2)修复了权限(即需要 sudo)问题。但是,在启动 grunt 之类的命令后,直到我运行 source ~/.profile 后才能使用。

有什么办法可以避免这种麻烦?

【问题讨论】:

    标签: node.js macos permissions .profile


    【解决方案1】:

    节点/NPM 设置是否创建了 ~/.bash_profile 或 ~/.bash_login 文件?如果是这样,bash 将在启动时获取它而不是 ~/.profile。如果这是问题所在,有几种方法可以解决:

    • 将 ~/.profile 文件的内容复制到 ~/.bash_profile(或 ~/.bash_login)。您可能还想删除 ~/.profile 以避免将来混淆。

    • 将命令添加到 ~/.bash_profile(或 ~/.bash_login)以获取 ~/.profile 以及:

      [ -f ~/.profile ] && source ~/.profile
      

    【讨论】:

    • 将导出从 ~/.profile 迁移到 ~/.bash_profile 解决了这个问题。
    猜你喜欢
    • 1970-01-01
    • 2021-07-10
    • 2019-06-09
    • 2018-01-23
    • 2019-01-12
    • 1970-01-01
    • 2021-03-13
    • 1970-01-01
    • 2018-08-24
    相关资源
    最近更新 更多