无法为我的React Native应用安装Realm。

23 浏览
0 Comments

无法为我的React Native应用安装Realm。

我正在尝试为我的React Native应用安装Realm,但是我遇到了以下错误,请问可能是什么问题呢?

我使用的命令是:

npm install --save realm

网址为:https://realm.io/docs/javascript/latest/

错误信息为:

npm ERR! Failed at the realm@2.11.0 install script.

我尝试过安装以下依赖:

npm install -g node-pre-gyp

npm install -g node-gyp

但是还是没有解决问题。请问还有什么建议吗?

谢谢!

R

以下是我的日志信息:

npm install --save realm

> realm@2.11.0 install C:\Development\abcd-Retail-ReactNative\retail-native-app\node_modules\realm

> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://static.realm.io/node-pre-gyp/2.11.0/realm-v2.11.0-node-v64-win32-x64.tar.gz

node-pre-gyp ERR! Pre-built binaries not found for realm@2.11.0 and node@10.1.0 (node-v64 ABI, unknown) (falling back to source compile with node-gyp)

gyp ERR! configure error

gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

gyp ERR! stack at PythonFinder.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)

gyp ERR! stack at PythonFinder. (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)

gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29

gyp ERR! stack at FSReqWrap.oncomplete (fs.js:165:21)

gyp ERR! System Windows_NT 10.0.16299

gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\Development\\abcd-Retail-ReactNative\\retail-native-app\\node_modules\\realm\\compiled\\node-v64_win32_x64\\realm.node" "--module_name=realm" "--module_path=C:\\Development\\abcd-Retail-ReactNative\\retail-native-app\\node_modules\\realm\\compiled\\node-v64_win32_x64"

gyp ERR! cwd C:\Development\abcd-Retail-ReactNative\retail-native-app\node_modules\realm

gyp ERR! node -v v10.1.0

gyp ERR! node-gyp -v v3.6.2

gyp ERR! not ok

node-pre-gyp ERR! build error

node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js

configure --fallback-to-build --module=C:\Development\abcd-Retail-ReactNative\retail-native-app\node_modules\realm\compiled\node-v64_win32_x64\realm.node --module_name=realm --module_path=C:\Development\abcd-Retail-ReactNative\retail-native-app\node_modules\realm\compiled\node-v64_win32_x64' (1)

node-pre-gyp ERR! stack at ChildProcess. (C:\Development\abcd-Retail-ReactNative\retail-native-app\node_modules\node-pre-gyp\lib\util\compile.js:83:29)

node-pre-gyp ERR! stack at ChildProcess.emit (events.js:182:13)

node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:957:16)

node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:246:5)

node-pre-gyp ERR! System Windows_NT 10.0.16299

node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Development\\abcd-Retail-ReactNative\\retail-native-app\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"

node-pre-gyp ERR! cwd C:\Development\abcd-Retail-ReactNative\retail-native-app\node_modules\realm

node-pre-gyp ERR! node -v v10.1.0

node-pre-gyp ERR! node-pre-gyp -v v0.6.39

node-pre-gyp ERR! not ok

Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Development\abcd-Retail-ReactNative\retail-native-app\node_modules\realm\compiled\node-v64_win32_x64\realm.node --module_name=realm --module_path=C:\Development\abcd-Retail-ReactNative\retail-native-app\node_modules\realm\compiled\node-v64_win32_x64' (1)

npm WARN eslint-plugin-react-native@3.2.1 requires a peer of eslint@^3.17.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN react-native@0.55.4 requires a peer of react@16.3.1 but none is installed. You must install peer dependencies yourself.

npm WARN react-native-looped-carousel@0.1.13 requires a peer of react-native@^0.54.0 but none is installed. You must install peer dependencies yourself.

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! realm@2.11.0 install: `node-pre-gyp install --fallback-to-build`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the realm@2.11.0 install script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Users\Rao\AppData\Roaming\npm-cache\_logs\2018-06-28T14_42_35_122Z-debug.log

0
0 Comments

无法在我的React Native应用程序中安装Realm

问题原因:Node版本不符合要求

解决方法:

1) 首先使用以下命令检查Node版本

node -v

如果版本与10.16.0不匹配,则使用以下链接安装Node

[https://nodejs.org/en/download/](https://nodejs.org/en/download/)

并安装Node 10.16.0

2) 使用以下命令安装Realm

npm install --save realm

Realm安装成功!!!

0
0 Comments

问题出现的原因是安装Realm时遇到了错误。解决方法如下:

1. 完全卸载机器上的Node.js,并重启电脑。

2. 从Node.js官网下载并安装稳定版本(8.11.3 LTS),然后重启机器。

3. 在项目中删除所有的node_modules,并通过npm install重新安装依赖。

4. 使用npm install --save realm命令安装Realm。

注意:如果之前安装了"node-pre-gyp"相关的包,需要先将其移除。

0