我开始研究 React Native。我首先通过官方文档中提到的步骤创建一个新项目 -
react-native init AwesomeProject
我得到这个错误。
This will walk you through creating a new React Native project in C:\Users\mihir
j\Desktop\Desktop\MOTO\ReactNative\AwesomeProject
Installing react-native package from npm...
> bufferutil@1.2.1 install C:\Users\mihirj\Desktop\Desktop\MOTO\ReactNative\Awes
omeProject\node_modules\react-native\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild
C:\Users\mihirj\Desktop\Desktop\MOTO\ReactNative\AwesomeProject\node_modules\rea
ct-native\node_modules\ws\node_modules\bufferutil>if not defined npm_config_node
_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\nod
e_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild )
> utf-8-validate@1.2.1 install C:\Users\mihirj\Desktop\Desktop\MOTO\ReactNative\
AwesomeProject\node_modules\react-native\node_modules\ws\node_modules\utf-8-vali
date
> node-gyp rebuild
C:\Users\mihirj\Desktop\Desktop\MOTO\ReactNative\AwesomeProject\node_modules\rea
ct-native\node_modules\ws\node_modules\utf-8-validate>if not defined npm_config_
node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..
\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild )
> spawn-sync@1.0.13 postinstall C:\Users\mihirj\Desktop\Desktop\MOTO\ReactNative
\AwesomeProject\node_modules\react-native\node_modules\yeoman-generator\node_mod
ules\cross-spawn\node_modules\spawn-sync
> node postinstall
The system cannot find the path specified.
The system cannot find the path specified.
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack at failNoPython (C:\Program Files\nodejs\node_modules\npm\nod
e_modules\node-gyp\lib\configure.js:116:14)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:71:11
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\mihirj\Desktop\Desktop\MOTO\ReactNative\AwesomeProject\nod
e_modules\react-native\node_modules\ws\node_modules\bufferutil
gyp ERR! node -v v4.2.3
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack at failNoPython (C:\Program Files\nodejs\node_modules\npm\nod
e_modules\node-gyp\lib\configure.js:116:14)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:71:11
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\mihirj\Desktop\Desktop\MOTO\ReactNative\AwesomeProject\nod
e_modules\react-native\node_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v4.2.3
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN optional dep failed, continuing bufferutil@1.2.1
npm WARN optional dep failed, continuing utf-8-validate@1.2.1
npm WARN optional dep failed, continuing fsevents@1.0.5
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "react-native"
npm ERR! node v4.2.3
npm ERR! npm v2.14.7
npm ERR! path C:\Users\mihirj\AppData\Roaming\npm-cache\minimist\1.2.0\package\p
ackage.json.f105b6c46a5308c8f62a234ec29f6abb
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\mihirj\AppData\
Roaming\npm-cache\minimist\1.2.0\package\package.json.f105b6c46a5308c8f62a234ec2
9f6abb' -> 'C:\Users\mihirj\AppData\Roaming\npm-cache\minimist\1.2.0\package\pac
kage.json'
npm ERR! at Error (native)
npm ERR! { [Error: EPERM: operation not permitted, rename 'C:\Users\mihirj\AppD
ata\Roaming\npm-cache\minimist\1.2.0\package\package.json.f105b6c46a5308c8f62a23
4ec29f6abb' -> 'C:\Users\mihirj\AppData\Roaming\npm-cache\minimist\1.2.0\package
\package.json']
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'C:\\Users\\mihirj\\AppData\\Roaming\\npm-cache\\minimist\\1.2.
0\\package\\package.json.f105b6c46a5308c8f62a234ec29f6abb',
npm ERR! dest: 'C:\\Users\\mihirj\\AppData\\Roaming\\npm-cache\\minimist\\1.2.
0\\package\\package.json',
npm ERR! parent: 'detect-indent' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\mihirj\Desktop\Desktop\MOTO\ReactNative\AwesomeProject\npm
-debug.log
`npm install --save react-native` failed
更新
我安装了python 2.7版。现在我收到了这个错误。
gyp: Call to 'node -e "require('nan')"' returned exit status 1. while trying to
load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Program Files\nodejs\node_module
s\npm\node_modules\node-gyp\lib\configure.js:355:16)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:200:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\mihirj\Desktop\Desktop\MOTO\ReactNative\AwesomeProject\nod
e_modules\react-native\node_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v4.2.3
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
The system cannot find the path specified.
gyp: Call to 'node -e "require('nan')"' returned exit status 1. while trying to
load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Program Files\nodejs\node_module
s\npm\node_modules\node-gyp\lib\configure.js:355:16)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:200:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\mihirj\Desktop\Desktop\MOTO\ReactNative\AwesomeProject\nod
e_modules\react-native\node_modules\ws\node_modules\bufferutil
gyp ERR! node -v v4.2.3
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN optional dep failed, continuing utf-8-validate@1.2.1
npm WARN optional dep failed, continuing bufferutil@1.2.1
npm WARN optional dep failed, continuing fsevents@1.0.5
`npm install --save react-native` failed