使用Mac终端安装react-native总是失败

时间:2017-08-23 06:18:01

标签: node.js git bash macos

当使用npm安装react native并运行时,我总是遇到react-native:command not found。即使我卸载npm并再次安装npm并运行...仍然失败。你能告诉我该怎么办?

这是我的日志:

Last login: Wed Aug 23 13:26:19 on console
Larrys-MacBook-Pro:~ larrylo$ npm install
npm WARN saveError ENOENT: no such file or directory, open '/Users/larrylo/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/Users/larrylo/package.json'
npm WARN larrylo No description
npm WARN larrylo No repository field.
npm WARN larrylo No README data
npm WARN larrylo No license field.

up to date in 0.153s
Larrys-MacBook-Pro:~ larrylo$ node -v
v8.4.0
Larrys-MacBook-Pro:~ larrylo$ npm -v
5.3.0
Larrys-MacBook-Pro:~ larrylo$ npm install npm@latest -g
/Users/larrylo/.npm-packages/bin/bin/npm -> /Users/larrylo/.npm-packages/bin/lib/node_modules/npm/bin/npm-cli.js
/Users/larrylo/.npm-packages/bin/bin/npx -> /Users/larrylo/.npm-packages/bin/lib/node_modules/npm/bin/npx-cli.js
+ npm@5.3.0
updated 1 package in 12.376s
Larrys-MacBook-Pro:~ larrylo$ git clone https://github.com/facebook/react-native.git
Cloning into 'react-native'...
remote: Counting objects: 153309, done.
remote: Compressing objects: 100% (102/102), done.
Receiving objects:  29% (44537/153309), 59.25 MiB | 107.00 KiB/s    

remote: Total 153309 (delta 86), reused 51 (delta 44), pack-reused 153163
Receiving objects: 100% (153309/153309), 137.87 MiB | 114.00 KiB/s, done.
Resolving deltas: 100% (107173/107173), done.
Larrys-MacBook-Pro:~ larrylo$ 
Larrys-MacBook-Pro:~ larrylo$ 
Larrys-MacBook-Pro:~ larrylo$ react-native init AwesomeProject
-bash: react-native: command not found
Larrys-MacBook-Pro:~ larrylo$ npm install -g react-native-cli

npm WARN gentlyRm not removing /Users/larrylo/.npm-packages/bin/bin/react-native as it wasn't installed by /Users/larrylo/.npm-packages/bin/lib/node_modules/react-native-cli
/Users/larrylo/.npm-packages/bin/bin/react-native -> /Users/larrylo/.npm-packages/bin/lib/node_modules/react-native-cli/index.js
+ react-native-cli@2.0.1
updated 1 package in 8.92s
Larrys-MacBook-Pro:~ larrylo$ 
Larrys-MacBook-Pro:~ larrylo$ react-native init AwesomeProject
-bash: react-native: command not found
Larrys-MacBook-Pro:~ larrylo$ 

每次运行终端时,我都必须安装react-native-cli并转到export PATH=/Users/larrylo/.npm-packages/bin/bin:$PATH

一次。这绝对是乏味的!

0 个答案:

没有答案