4

I am trying to install Realm for my React native app and I get the following error, could you suggest what might be wrong.

I am using the command

npm install --save realm

from the web - https://realm.io/docs/javascript/latest/

Error:

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

I have tried to install

npm install -g node-pre-gyp

and

npm install -g node-gyp

Still did not work. any suggestions would be very helpful

Thanks R

here is my log

    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
BRDroid
  • 3,920
  • 8
  • 65
  • 143

2 Answers2

2

Thanks @Ashwin Mothilal, I had to go back to a stable version of Node (v8.11.3). How I did it.

It took a while to figure out the entire procedure, writing down the steps I performed. Hope this helps

1 - Uninstalled Node.js completely from my machine. (Windows) Followed this link - [How to completely remove node.js from Windows (Dont forget to restart your PC)

2 - Downloaded and Installed the stable version (8.11.3 LTS) from - [https://nodejs.org/en/][1]

3 - Restart your machine.

4 - Check the node version now (>> node -v).

5 - In your project remove all node_modules - rm -rf node_modules/ npm install link - [How to clean node_modules folder of packages that are not in package.json?

6 - then do - >>npm install in your project. This should install all the required dependencies.

7 - Now install Realm.

npm install --save realm

This has successfully added Realm to my project.

Note: When I was getting this errors which I have posted in my actual question, It recommended me to install 'node-pre-gyp'. I tried to install

  npm install --save node-pre-gyp --fallback-to-build
  npm install --save node-pre-gyp
  npm install -g node-pre-gyp 

Which did not work, so Before I did the steps provided above I have removed 'node-pre-gyp'. In case you have installed any of the above you can please remove them as it was not required.

Hope this helps. R

BRDroid
  • 3,920
  • 8
  • 65
  • 143
0

1) First Check Node version using below command

node -v
v10.16.0

If Version is not match with 10.16.0 than install node using below link

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

and install node 10.16.0

Blockquote

Install realm using below command

npm install --save realm

Realm install successfully.!!!

Pratik Panchal
  • 339
  • 5
  • 13