【问题标题】:react-native init Awesomeproject "npm ERR! Please try running this command again as root/Administrator." windows 10react-native init Awesomeproject "npm ERR!请尝试以 root/管理员身份再次运行此命令。"窗户 10
【发布时间】:2015-12-20 20:21:36
【问题描述】:

我正在尝试按照"Getting started with react-native" 的说明进行操作。

我知道将 windows 用于我的开发平台是实验性的,但这就是我正在做的事情。我启动“Node.js 命令提示符”然后执行...

> npm install -g react-native-cli
> react-native init AwesomeProject

...但我收到此错误...

C:\Users\plankton>react-native init AwesomeProject
This will walk you through creating a new React Native project in C:\Users\plankton\AwesomeProject
Installing react-native package from npm...

> bufferutil@1.2.1 install C:\Users\plankton\AwesomeProject\node_modules\react-native\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild


C:\Users\plankton\AwesomeProject\node_modules\react-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\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  bufferutil.cc
  win_delay_load_hook.c
     Creating library C:\Users\plankton\AwesomeProject\node_modules\react-native\node_modules\ws\node_modules\bufferutil\build\Release\bufferutil.lib and object C:\Users\plankton\AwesomeProject\node_modules\react-native\node_modules\ws\node_modules\bufferutil\build\Release\bufferutil.exp
  Generating code
  Finished generating code
  bufferutil.vcxproj -> C:\Users\plankton\AwesomeProject\node_modules\react-native\node_modules\ws\node_modules\bufferutil\build\Release\\bufferutil.node

> utf-8-validate@1.2.1 install C:\Users\plankton\AwesomeProject\node_modules\react-native\node_modules\ws\node_modules\utf-8-validate
> node-gyp rebuild


C:\Users\plankton\AwesomeProject\node_modules\react-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 )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  validation.cc
  win_delay_load_hook.c
     Creating library C:\Users\plankton\AwesomeProject\node_modules\react-native\node_modules\ws\node_modules\utf-8-validate\build\Release\validation.lib and object C:\Users\plankton\AwesomeProject\node_modules\react-native\node_modules\ws\node_modules\utf-8-validate\build\Release\validation.exp
  Generating code
  Finished generating code
  validation.vcxproj -> C:\Users\plankton\AwesomeProject\node_modules\react-native\node_modules\ws\node_modules\utf-8-validate\build\Release\\validation.node

> spawn-sync@1.0.13 postinstall C:\Users\plankton\AwesomeProject\node_modules\react-native\node_modules\yeoman-generator\node_modules\cross-spawn\node_modules\spawn-sync
> node postinstall


npm WARN optional dep failed, continuing fsevents@1.0.6
npm ERR! Windows_NT 10.0.10586
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\plankton\AppData\Roaming\npm-cache\brace-expansion\1.1.2\package\package.json.9d769f6c66df6b0ff357401140ec21e2
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\plankton\AppData\Roaming\npm-cache\brace-expansion\1.1.2\package\package.json.9d769f6c66df6b0ff357401140ec21e2' -> 'C:\Users\plankton\AppData\Roaming\npm-cache\brace-expansion\1.1.2\package\package.json'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM: operation not permitted, rename 'C:\Users\plankton\AppData\Roaming\npm-cache\brace-expansion\1.1.2\package\package.json.9d769f6c66df6b0ff357401140ec21e2' -> 'C:\Users\plankton\AppData\Roaming\npm-cache\brace-expansion\1.1.2\package\package.json']
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\plankton\\AppData\\Roaming\\npm-cache\\brace-expansion\\1.1.2\\package\\package.json.9d769f6c66df6b0ff357401140ec21e2',
npm ERR!   dest: 'C:\\Users\\plankton\\AppData\\Roaming\\npm-cache\\brace-expansion\\1.1.2\\package\\package.json',
npm ERR!   parent: 'minimatch' }
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\plankton\AwesomeProject\npm-debug.log

`npm install --save react-native` failed

错误输出提示:Please try running this command again as root/Administrator.,但我如何在 Windows 10 系统上执行此操作?

更新:感谢 Louy,您的回答有效。这是我最终所做的屏幕截图...

右击Node.js command promtpt并选择Run as Administrator

更新二:在随后的迭代中,我得到了同样的错误。我当时要做的就是Louy在评论中说要做的事情:

删除文件夹"C:\\Users\\plankton\\AppData\\Roaming\\npm-cache

更新三:

我以管理员身份运行了 Node.js 命令提示符,并删除了文件夹 "C:\\Users\\plankton\\AppData\\Roaming\\npm-cache,但仍然出现 running this command again as root/Administrator 错误。我必须使用 Windows 资源管理器从“C:\Users\plankton\AppData` 文件夹中取消设置 Read onlyhidden 属性。

【问题讨论】:

  • 可能是您以前以管理员身份安装了一些东西。您是否尝试删除文件夹“C:\\Users\\plankton\\AppData\\Roaming\\npm-cache”?

标签: android node.js windows react-native


【解决方案1】:

您需要以管理员身份启动命令行解释器。

  • 打开开始菜单
  • 键入“cmd”
  • 右键单击并选择“以管理员身份运行”

然后像之前一样做。

【讨论】:

  • 谢谢!做到了。我将在我的答案中添加一个屏幕截图,显示您建议的外观。
猜你喜欢
  • 1970-01-01
  • 2014-04-15
  • 2018-05-18
  • 2018-04-22
  • 2018-02-22
  • 2014-12-24
  • 1970-01-01
  • 1970-01-01
  • 2021-12-29
相关资源
最近更新 更多