简体   繁体   English

在Windows上初始化新项目时反应本机错误

[英]React native error on init new project on windows

I started working on react native. 我开始研究本机。 I started by creating a new project through the steps mentioned in the official documentation - 我首先通过官方文档中提到的步骤创建了一个新项目-

react-native init AwesomeProject

I get this error. 我得到这个错误。

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

UPDATE 更新

I installed python version 2.7. 我安装了python版本2.7。 Now I am getting this error. 现在我收到此错误。

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

Probably the NPM version is old. NPM版本可能很旧。 To overcome this issue I've tried the following steps. 为解决此问题,我尝试了以下步骤。

But before, the version of NPM may be checked. 但是在此之前,可以检查NPM的版本。 npm -v command shows the current installed NPM version. npm -v命令显示当前已安装的NPM版本。 And npm view npm version command shows the current version of manufacturer. npm view npm version命令显示了制造商的当前版本。

If needs to update continue; 如果需要更新继续;

  • Delete C:\\Users\\UserName\\AppData\\Roaming\\npm and C:\\Users\\UserName\\AppData\\Roaming\\npm-cache 删除C:\\Users\\UserName\\AppData\\Roaming\\npmC:\\Users\\UserName\\AppData\\Roaming\\npm-cache
  • Reinstall NPM by using the command of npm install npm -g 使用npm install npm -g命令重新安装NPM
  • Install as a global module the React Native CLI by using the command of npm install -g react-native-cli 使用npm install -g react-native-cli命令将React Native CLI作为全局模块npm install -g react-native-cli

And now, new npm and node-gyp is ready to use! 现在,新的npmnode-gyp可以使用了!

  • Retry the command of react-native init AwesomeProject 重试react-native init AwesomeProject的命令

I hope it helps. 希望对您有所帮助。

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

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