在ubuntu 16.04 LTS中找不到create-react-app命令

时间:2017-11-12 19:58:05

标签: reactjs create-react-app

我尝试在终端上使用sudo npm install -g create-react-app安装create react app,然后出现以下消息:

/home/mahi/.npm-global/bin/create-react-app -> /home/mahi/.npm-global/lib/node_modules/create-react-app/index.js + create-react-app@1.4.3 updated 1 package in 11.7s

然后,当我要运行命令create-react-app hello-world时,它表示找不到create-react-app命令。然后我搜索了许多解决方案,我几乎尝试了所有这些解决方案,但没有任何改进,显示一次又一次找不到命令。

5 个答案:

答案 0 :(得分:5)

我遇到了同样的问题,这就是我解决的方法。 它将在Ubuntu 16.04和Ubuntu 18.04上运行。

首先,打开终端并运行以下命令:

sudo npm install -g -y create-react-app

在那之后,您将可以在计算机上的任何地方使用create-react-app,因为它是全局保存的。

答案 1 :(得分:0)

你确定要用sudo运行npm install吗?我有同样的问题,终端无法用命令写入文件夹。您的/usr/local/lib/node_modules/文件夹是否包含create-react-app

答案 2 :(得分:0)

are you using create-react-app with sudo? because if you installed the package using sudo npm install create-react-app then it is installed for this user, try sudo create-react-app and if it works then you should change ownership to your user

答案 3 :(得分:0)

当我编写npm install -g create-react-app时,我在终端上也遇到同样的问题,而他们创建了my-first-app。 所以我去了反应文档,我发现npx create-react-app my-first-app对我有用。

希望会有所帮助。

答案 4 :(得分:0)

  

如果您仔细阅读,则会在安装Yarn后看到它告诉您在路径中添加以下内容。

     
{ [Function: d] unless: [Function], UnauthorizedError: [Function: r] }
     

export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" 仅适用于纱线二进制文件。

尝试一下!

来源:https://github.com/yarnpkg/yarn/issues/5156

相关问题