无法安装create-react-app

时间:2017-04-15 03:07:43

标签: javascript node.js reactjs npm yarnpkg

我关注https://hackernoon.com/simple-react-development-in-2017-113bd563691f
我是React生态系统的新手,我刚刚安装了Yarn

➜  WebstormProjects yarn --version
0.23.2

然后我安装了文档中提到的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.

然后,我尝试创建应用

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

然后,我前往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

我拥有的nodenpm版本

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

我犯了什么错误?

2 个答案:

答案 0 :(得分:2)

基于npm的输出,它将您的命令解释为尝试全局安装本地目录中包含的包。您可能想在同一目录中尝试rm -rf create-react-app && sudo npm i -g create-react-app

答案 1 :(得分:1)

  1. 尝试使用“以管理员身份运行”来运行终端
  2. 从Cd到〜cookie in Browser
  3. 运行命令cd ~
  4. 然后运行命令npm cache clean --force
  5. 现在再次运行命令npm install -g npm@latest --force
  6. 最后,运行命令npm cache clean --force
  7. 如果有效,请通知我,使用超级终端进行安装