LoginSignup
8
5

More than 5 years have passed since last update.

突然gulpが変なエラー吐き出したのでnodeのバージョンをダウンした

Posted at

突然うちのgulpがおう吐するようになりました。
何度呼んでも以下のようなエラーを吐くのです。。

$ gulp
gulp[7570]: ../src/node_contextify.cc:631:static void node::contextify::ContextifyScript::New(const FunctionCallbackInfo<v8::Value> &): Assertion `args[1]->IsString()' failed.
 1: node::Abort() [/usr/local/bin/node]
 2: node::Assert(char const* const (*) [4]) [/usr/local/bin/node]
 3: node::contextify::ContextifyScript::New(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
 4: v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) [/usr/local/bin/node]
 5: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<true>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/node]
 6: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node]
 7: 0x1f00c118427d
Abort trap: 6

救急車呼びか、病院に連れて行くか悩みましたが、ひとまず自分で対応することにしました。

結論

nodeのバージョンに対応してなかったぽい

以前まではv8.9.4で実行していましたが、別の用事でnodeのバージョンをv10.0.0にしたら今のgulpにはちょっと合わなかった見たいです。

対応

とりあえずnodeのバージョンをv8.9.4に戻すことにしました。

ただ、僕のmacでは、homebrew管理のものとnodebrew管理のものがあり、homebrew管理のものがv10.0.0、nodebrew管理のものがv8.9.4でした。
そしてhomebrewの方のnodeが使われているようでした。

homebrewよりnodebrewの方がいい的な記事があったので、nodebrewに変えることにしました。
そのため、以下の手順で対応しました。
①homebrew管理のnodeをuninstall
②nodebrew管理のnodeにパスを通す

①homebrew管理のnodeをuninstall

yarnをインストールしていたのでnodeをアンインストール出来ませんでした。
なので両方アンインストール。

$ brew uninstall --force yarn
$ brew uninstall --force node

②nodebrew管理のnodeにパスを通す

※nodebrewはインストール済み

とりあえずnodebrewのディレクトリ設定
(homebrew経由でnodebrewをインストールした場合に手動で行う必要があるらしい)

/usr/local/opt/nodebrew/bin/nodebrew setup_dirs

パスを通す

export PATH=$HOME/.nodebrew/current/bin:$PATH

~/.nodebrewではなくhomebrewのディレクトリを使う場合は以下を実行

export NODEBREW_ROOT=/usr/local/var/nodebrew

最後にnpm install(パッケージのバージョンは変えたくなかったので)

$ npm install

結果

無事元気なgulpに会うことが出来ました。

$ gulp
[17:47:19] Using gulpfile ~/Develop
[17:47:19] Starting 'watch'...
[17:47:20] Finished 'watch' after 549 ms
[17:47:20] Starting 'default'...
[17:47:20] Finished 'default' after 24 μs

参考

Node.jsの管理をHomebrewからnodebrewに変える

8
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
5