无法为我的React Native App安装Realm

时间:2018-06-28 15:14:55

标签: react-native npm realm

我正在尝试为我的React本机应用程序安装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.<anonymous> (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.<anonymous> (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

2 个答案:

答案 0 :(得分:0)

感谢@Ashwin Mothilal,我不得不回到稳定版本的Node(v8.11.3)。我是怎么做到的。

花了一段时间才能弄清楚整个过程,写下我执行的步骤。希望这会有所帮助

1-完全从我的计算机上卸载了Node.js。 (视窗)    跟随了此链接-[{How to completely remove node.js from Windows    (不要忘记重启电脑)

2-从以下位置下载并安装了稳定版本(8.11.3 LTS):    [https://nodejs.org/en/][1]

3-重新启动计算机。

4-现在检查节点版本(>>节点-v)。

5-在您的项目中,删除所有node_modules-     rm -rf node_modules /     npm安装    链接- [How to clean node_modules folder of packages that are not in package.json?

6-然后在您的项目中执行>> >> .class-name-of-checkboxes。     这应该安装所有必需的依赖项。

7-现在安装Realm。

npm install

这已成功将Realm添加到我的项目中。

注意:     当我收到我在实际问题中发布的错误时,它建议我安装'node-pre-gyp'。 我尝试安装

npm install --save realm

这不起作用,因此在执行上面提供的步骤之前,我已经删除了“ node-pre-gyp”。如果您已安装上述任何软件,则可以将其删除,因为这不是必需的。

希望这会有所帮助。 R

答案 1 :(得分:0)

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

  

node -v
       v10.16.0

如果版本与10.16.0不匹配,则使用下面的链接安装节点

  

https://nodejs.org/en/download/

并安装节点10.16.0

  

Blockquote

使用以下命令安装领域

  

npm install --save realm

领域安装成功。!!!