NVM 安装错误:找不到配置文件。尝试过 ~/.bashrc、~/.bash_profile、~/.zshrc 和 ~/.profile。

问题描述 投票:0回答:4

我刚刚擦除并重新格式化了我的整个 Macbook Retina 驱动器,从头开始, 安装了自制程序, 安装了 xcode 并接受了条款和条件, 使用

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
安装 nvm 并收到以下错误:

=> nvm is already installed in /Users/dillon/.nvm, trying to update using git
=> => Compressing and cleaning up git repository

=> Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
=> Create one of them and run this script again
   OR
=> Append the following lines to the correct file yourself:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
如果有帮助的话,

echo $PATH
返回
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

我尝试在 github 上打开问题但尚未收到回复

知道我可以做什么来让 nvm 和节点正常运行吗?

node.js nvm
4个回答
15
投票

没有从 nvm 安装说明中阅读此内容。它解决了我的问题。

注意:在 OS X 上,如果运行以下命令后收到 nvm: command not found 安装脚本,以下原因之一可能是:-

your system may not have a [.bash_profile file] where the command is set up. Simply create one with touch ~/.bash_profile and run the

再次安装脚本 您可能需要重新启动终端实例。尝试在终端中打开一个新选项卡/窗口并重试。


0
投票

以下命令解决了我的问题:

sudo chown -R $USER:$(id -gn $USER) /Users/david/.config

注意:更改您的用户路径中的“david”。


0
投票
  1. touch ~/.bash_profile
  2. 重新运行 nvm install 命令
  3. 完全退出并重新打开终端
  4. nvm -v
    现在应该可以正常工作了

问题是 bash 不知道 nvm 在哪里。您需要一个 bash_profile 文件来告诉 bahs 去哪里查找。安装 nvm 不会为您创建此文件,但它会插入告诉它在哪里查找的指令。


0
投票

对于任何使用 Windows Git Bash 的人,您都希望将丢失的文件(例如

.bashrc
)添加到您的
%USERPROFILE%
文件夹中。

© www.soinside.com 2019 - 2024. All rights reserved.