Node.js
npm
nodebrew
reactnative

npm iでエラー「node-pre-gyp ERR! Pre-built binaries not found for fsevents@1.1.3 and node@10.0.0」

起きた問題

React Nativeのディレクトリで npm i したらエラー

前提

nodebrewで管理


$ node -v
v10.0.0
$ npm -v
5.6.0

エラー


NonomeRyutaroMacBookPro:HogeApp nonomeryutaro$ rm -rf node_modules/ && npm i
npm WARN npm npm does not support Node.js v10.0.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/

> fsevents@1.1.3 install /Users/nonomeryutaro/Projects/HogeApp/node_modules/fsevents
> node install

node-pre-gyp ERR! Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.1.3/fse-v1.1.3-node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for fsevents@1.1.3 and node@10.0.0 (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
In file included from ../fsevents.cc:6:
../../nan/nan.h:839:18: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations]
    return node::MakeCallback(
                 ^
/Users/nonomeryutaro/.node-gyp/10.0.0/include/node/node.h:171:1: note: 'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/nonomeryutaro/.node-gyp/10.0.0/include/node/node.h:88:20: note: expanded from macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                   ^
In file included from ../fsevents.cc:6:
../../nan/nan.h:854:18: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations]
    return node::MakeCallback(
                 ^
/Users/nonomeryutaro/.node-gyp/10.0.0/include/node/node.h:164:1: note: 'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/nonomeryutaro/.node-gyp/10.0.0/include/node/node.h:88:20: note: expanded from macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                   ^
In file included from ../fsevents.cc:6:
../../nan/nan.h:869:18: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations]
    return node::MakeCallback(
                 ^
/Users/nonomeryutaro/.node-gyp/10.0.0/include/node/node.h:157:1: note: 'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/nonomeryutaro/.node-gyp/10.0.0/include/node/node.h:88:20: note: expanded from macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                   ^
In file included from ../fsevents.cc:6:
../../nan/nan.h:1648:31: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations]
    return scope.Escape(node::MakeCallback(
                              ^
/Users/nonomeryutaro/.node-gyp/10.0.0/include/node/node.h:171:1: note: 'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/nonomeryutaro/.node-gyp/10.0.0/include/node/node.h:88:20: note: expanded from macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                   ^
In file included from ../fsevents.cc:85:
../src/methods.cc:14:12: warning: 'Call' is deprecated [-Wdeprecated-declarations]
  handler->Call(3, argv);
           ^
../../nan/nan.h:1567:3: note: 'Call' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value>
  ^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
5 warnings generated.
  SOLINK_MODULE(target) Release/fse.node
  COPY /Users/nonomeryutaro/Projects/HogeApp/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node
  TOUCH Release/obj.target/action_after_build.stamp

> realm@2.3.2 install /Users/nonomeryutaro/Projects/HogeApp/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.3.2/realm-v2.3.2-node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for realm@2.3.2 and node@10.0.0 (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
  TOUCH Release/obj.target/OpenSSL.stamp
  ACTION binding_gyp_vendored_realm_target_download_realm /Users/nonomeryutaro/Projects/HogeApp/node_modules/realm/vendor/realm-mac-x64
Resolved requirements: { SYNC_SERVER_FOLDER: 'sync',
  SYNC_ARCHIVE: 'realm-sync-node-cocoa-3.0.0.tar.gz',
  SYNC_ARCHIVE_ROOT: 'realm-sync-node-cocoa-3.0.0' }
No lockfile found at the target, proceeding.
Download url: https://static.realm.io/downloads/sync/realm-sync-node-cocoa-3.0.0.tar.gz
Extracting realm-sync-node-cocoa-3.0.0.tar.gz => /Users/nonomeryutaro/Projects/HogeApp/node_modules/realm/vendor/realm-mac-x64
Success
  TOUCH Release/obj.target/vendored-realm.stamp
  TOUCH Release/obj.target/realm-core.stamp
  TOUCH Release/obj.target/realm-sync.stamp
  CXX(target) Release/obj.target/object-store/src/object-store/src/binding_callback_thread_observer.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/collection_notifications.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/index_set.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/list.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/object.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/placeholder.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/object_schema.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/object_store.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/results.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/schema.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/shared_realm.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/thread_safe_reference.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/impl/collection_change_builder.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/impl/collection_notifier.o
  CXX(target) Release/obj.target/object-store/src/object-store/src/impl/list_notifier.o
^Cmake: *** [Release/obj.target/object-store/src/object-store/src/impl/list_notifier.o] Interrupt: 2

<以下略>

原因箇所


node-pre-gyp ERR! Tried to download(404): https://static.realm.io/node-pre-gyp/2.3.2/realm-v2.3.2-node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for realm@2.3.2 and node@10.0.0 (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
  TOUCH Release/obj.target/OpenSSL.stamp
  ACTION binding_gyp_vendored_realm_target_download_realm /Users/nonomeryutaro/Projects/HogeApp/node_modules/realm/vendor/realm-mac-x64
Resolved requirements: { SYNC_SERVER_FOLDER: 'sync',
  SYNC_ARCHIVE: 'realm-sync-node-cocoa-3.0.0.tar.gz',
  SYNC_ARCHIVE_ROOT: 'realm-sync-node-cocoa-3.0.0' }

原因

nodeのバージョン

解決方法

nodeのバージョンを9.11.0にする。

解決手順


# v9.11.0をインストール
$ nodebrew install-binary v9.11.0
Fetching: https://nodejs.org/dist/v9.11.0/node-v9.11.0-darwin-x64.tar.gz
######################################################################## 100.0%
Installed successfully

# 現在v10.0.0のため、v9.11.0を使うよう設定する。
$ node -v
v10.0.0
$ nodebrew use v9.11.0
use v9.11.0

# 確認
$ node -v
v9.11.0

感想

めっちゃ大変でした()

別記

他に起きた不具合

・nodeのバージョンが変わらない
・nodeで -bash command not found
・npmで -bash command not found


$ nodebrew use v9.11.0
use v9.11.0

$ node -v
v10.0.0

解決策

.bash_profileを触りました


$ vim ~/.bash_profile

# .bash_profile

## Before
export PATH=$HOME/.nodebrew/current/bin:$PATH
export NODEBREW_ROOT=/usr/local/var/nodebrew

## After
export PATH=/usr/local/var/nodebrew/current/bin:$PATH
export NODEBREW_ROOT=/usr/local/var/nodebrew

$ source ~/.bash_profile

# 確認
$ which node
/usr/local/var/nodebrew/current/bin/node
$ which npm
/usr/local/var/nodebrew/current/bin/npm

以上