create-react-app目前无法正常工作

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

我跑了npm install create-react-app -g然后

create-react-app hello-world

回报

-bash: create-react-app: command not found

据我所知,我的$PATH目前搞砸了。这是从echo $PATH返回的内容

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

我真的不知道该怎么做,因为我目前对终端很新。任何帮助将不胜感激。谢谢!

reactjs terminal path create-react-app
5个回答
3
投票

只需将路径导出到.bashrc,然后从$ home目录中的.profile文件中调用它,然后重新启动。例如:.bashrc文件:

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

.profile文件:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
       . "$HOME/.bashrc"
    fi
fi

 # set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

0
投票

我不是100%肯定你的问题的答案。然而;如果你只是想设置一个反应环境,我建议你参考一下关于React的Youtube教程。在您想要的目录上创建一个文件夹,然后使用命令提示符,gitBash或Cygwin转到特定目录,并使用NodeJs,您可以安装开始所需的一切。按照前10分钟进行设置,然后您就可以了走。祝好运

https://www.youtube.com/watch?v=IR6smI_YJDE&t=278s&list=PLbeWHDJFd79RXvAeGaDXMmxL_tkb3MvdH&index=1


0
投票

将npm-packages添加到.bash_profile中的路径中

echo 'export PATH="$HOME/.npm-packages/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

0
投票

我有同样的问题,虽然长期修复你的$ PATH修复,但我可以给你“快速和肮脏”的方式来启动你的创建反应应用程序。

这是我在安装create-react-app之后得到的输出,我使用路径来使用该命令

BatMan-MacBook-Pro:coursera-react batman$ sudo npm install -g create-react-app

/Users/batman/.npm-packages/bin/create-react-app -> /Users/batman/.npm-packages/lib/node_modules/create-react-app/index.js
+ [email protected]
updated 1 package in 2.594s

我使用上面的路径来实现它并且它起作用了。

BatMan-MacBook-Pro:coursera-react batman$ /Users/batman/.npm-packages/bin/create-react-app BatManCafe

0
投票

所以我最近遇到了这个问题,那是因为我只是输入create-react-app [app-name]

如果有人再遇到这个问题,请输入npx create-react-app [app-name]npm init react-app [app-name]yarn create react-app [app-name]

https://facebook.github.io/create-react-app/docs/getting-started

希望有人帮助!

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.