zsh:找不到命令:react-native-MacOS

时间:2019-02-12 12:45:35

标签: macos react-native

我正在尝试启动本机响应,但是在编写zsh: command not found: react-native时收到以下错误react-native init firstApp

我尝试了以下指南:react-native: command not found

但是我有两个主要问题:

第一 我不知道要使用/导出哪个路径

本机安装在这里:

/Users/cisco/.npm-packages/bin/react-native -> /Users/cisco/.npm-packages/lib/node_modules/react-native/local-cli/wrong-react-native.js 

第二

在本指南中,它被编写为运行:

export PATH="/usr/local/Cellar/node/6.1.0/libexec/npm/bin:$PATH"   
react-native init appName  
cd appName   
react-native run-ios

我不知道如何:

1) export PATH=

之后写的内容

2)我应该在哪里添加路径吗?如果是,我该怎么办? 我尝试运行touch ~/.bash_profile; open ~/.bash_profile添加路径。

里面有我

# added by Anaconda3 5.3.1 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<
# added by Anaconda3 2018.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/cisco/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/Users/cisco/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/cisco/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/Users/cisco/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

一旦您帮助我确定正确的路径后再添加,我可以简单地将其添加到# <<< conda init <<<? 行下面的文件中吗

3 个答案:

答案 0 :(得分:0)

因为您正在使用zsh。您可以在〜/ .zshrc

中添加export PATH=/Users/cisco/.npm-packages/bin/react-native:$PATH

答案 1 :(得分:0)

解决了!

步骤:

1)运行npm list -g | head -n 1

它将为您提供类似于以下内容的路径:/Users/cisco/.npm-packages/lib

2)通过用/lib代替/bin:$PATH来更改该路径,这样您将获得:/Users/cisco/.npm-packages/bin:$PATH

3)运行export PATH="/Users/cisco/.npm-packages/bin:$PATH"

答案 2 :(得分:0)

此操作对我来说很好。只需按照以下说明进行操作即可。

默认的交互式shell现在是zsh。 要更新您的帐户以使用zsh,请运行

chsh -s /bin/zsh