0
我開始研究反應本機。我開始通過在官方文檔中提到的步驟創建一個新項目 -在Windows上初始化新項目時出現本機錯誤
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...
> [email protected] 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)
> [email protected] 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)
> [email protected] 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 [email protected]
npm WARN optional dep failed, continuing [email protected]
npm WARN optional dep failed, continuing [email protected]
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
UPDATE
我安裝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 [email protected]
npm WARN optional dep failed, continuing [email protected]
npm WARN optional dep failed, continuing [email protected]
`npm install --save react-native` failed
https://github.com/nodejs/node-gyp 也許node-gyp頁面可能有一些答案給你? – Goblinlord
@Goblinlord爲node-gyp配置python的路徑,但仍然不能正常工作 – mjosh
在windows下列出的python有更多要求 – Goblinlord