React Native创建项目时报错:npm ERR! Windows_NT 10.0.10240 错误

1.问题描述


React Native创建项目时报一堆的错:


spawn-sync@1.0.15 postinstall D:\RN_Android\app_projects\fendo\node_modules\react-native\node_modules\yeoman-generator\node_modules\cross-spawn\node_modules\spawn-sync
> node postinstall


npm WARN peerDependencies The peer dependency react@~15.3.1 included from react-native will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN deprecated cross-spawn-async@2.2.4: cross-spawn no longer requires a build toolchain,use it instead!
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\sowafort\\nodejs\\node.exe" "C:\\sowafort\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "--save-exact" "react-native"
npm ERR! node v4.5.0
npm ERR! npm v2.15.9
npm ERR! path C:\Users\fendo\AppData\Roaming\npm-cache\babel-traverse\6.16.0\package.tgz.1360063874
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename


npm ERR! Error: EPERM: operation not permitted,rename 'C:\Users\fendo\AppData\Roaming\npm-cache\babel-traverse\6.16.0\package.tgz.1360063874' -> 'C:\Users\fendo\AppData\Roaming\npm-cache\babel-traverse\6.16.0\package.tgz'
npm ERR! at Error (native)
npm ERR! { [Error: EPERM: operation not permitted,rename 'C:\Users\fendo\AppData\Roaming\npm-cache\babel-traverse\6.16.0\package.tgz.1360063874' -> 'C:\Users\fendo\AppData\Roaming\npm-cache\babel-traverse\6.16.0\package.tgz']
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'C:\\Users\\fendo\\AppData\\Roaming\\npm-cache\\babel-traverse\\6.16.0\\package.tgz.1360063874',
npm ERR! dest: 'C:\\Users\\fendo\\AppData\\Roaming\\npm-cache\\babel-traverse\\6.16.0\\package.tgz',
npm ERR! parent: 'babel-plugin-transform-es2015-classes' }
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! D:\RN_Android\app_projects\fendo\npm-debug.log



`npm install --save --save-exact react-native` Failed


2.解决方法


由于我是win10的系统,并没有用管理员运行Dos所以他才会报错,win+x然后以管理员运行Dos就行了。

相关文章

react 中的高阶组件主要是对于 hooks 之前的类组件来说的,如...
我们上一节了解了组件的更新机制,但是只是停留在表层上,例...
我们上一节了解了 react 的虚拟 dom 的格式,如何把虚拟 dom...
react 本身提供了克隆组件的方法,但是平时开发中可能很少使...
mobx 是一个简单可扩展的状态管理库,中文官网链接。小编在接...
我们在平常的开发中不可避免的会有很多列表渲染逻辑,在 pc ...