简体   繁体   English

无法安装 create-react-app

[英]unable to install create-react-app

I am following https://hackernoon.com/simple-react-development-in-2017-113bd563691f我正在关注https://hackernoon.com/simple-react-development-in-2017-113bd563691f
I am new to React ecosystem and I just now installed Yarn我是React生态系统的新手,我刚刚安装了Yarn

➜  WebstormProjects yarn --version
0.23.2

Then I installed created-react-app as mentioned in the docs as然后我按照文档中的说明安装了created-react-app

➜  WebstormProjects yarn global add create-react-app
yarn global v0.23.2
warning No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Installed "create-react-app@1.3.0" with binaries:
      - create-react-app
warning No license field
✨  Done in 0.82s.

Then, I tried creating app然后,我尝试创建应用程序

➜  WebstormProjects create-react-app myproject
zsh: command not found: create-react-app

Then, I headed over https://github.com/facebookincubator/create-react-app and tried installing using npm as然后,我前往https://github.com/facebookincubator/create-react-app并尝试使用npm安装

➜  WebstormProjects npm install -g create-react-app

npm ERR! addLocal Could not install /Users/Harit.Himanshu/WebstormProjects/create-react-app
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/7.9.0/bin/node" "/usr/local/bin/npm" "install" "-g" "create-react-app"
npm ERR! node v7.9.0
npm ERR! npm  v4.2.0

npm ERR! No name provided in package.json
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Harit.Himanshu/.npm/_logs/2017-04-15T03_06_22_478Z-debug.log

The node and npm versions I have are我拥有的nodenpm版本是

➜  WebstormProjects node --version
v7.9.0
➜  WebstormProjects npm --version
4.2.0
➜  WebstormProjects

What mistake I am making?我犯了什么错误?

Based on npm 's output, it's interpreting your command as an attempt to install a package contained in a local directory globally.根据npm的输出,它将您的命令解释为尝试全局安装包含在本地目录中的包。 You might want to try rm -rf create-react-app && sudo npm i -g create-react-app within that same directory.您可能想在同一目录中尝试rm -rf create-react-app && sudo npm i -g create-react-app

  1. Try to run the terminal with Run as Administrator尝试以管理员身份运行终端
  2. Cd to ~ cd ~ cd to ~ cd ~
  3. Run the command npm cache clean --force运行命令npm cache clean --force
  4. Then run the command npm install -g npm@latest --force然后运行命令npm install -g npm@latest --force
  5. Now again run the command npm cache clean --force现在再次运行命令npm cache clean --force
  6. Finally, run the command npx create-react-app my-app最后,运行命令npx create-react-app my-app
  7. If it works let me know, Used HYPER TERMINAL to install如果可行,请告诉我,使用 HYPER TERMINAL 进行安装

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM