現象
npm installしようとしたらこんなエラーが出て怒られた
$ npm install
WARNING: You are likely using a version of node-tar or npm that is incompatible with this version of Node.js.
Please use either the version of npm that is bundled with Node.js, or a version of npm (> 5.5.1 or < 5.4.0) or node-tar (> 4.0.1) that is compatible with Node.js 9 and above.
npm[14907]: ../src/node_zlib.cc:551:static void node::(anonymous namespace)::ZlibStream::Init(const FunctionCallbackInfo<v8::Value> &): Assertion `args.Length() == 7 && "init(windowBits, level, memLevel, strategy, writeResult, writeCallback," " dictionary)"' failed.
1: 0x10003cf99 node::Abort() [/usr/local/bin/node]
2: 0x10003bfbb node::AddEnvironmentCleanupHook(v8::Isolate*, void (*)(void*), void*) [/usr/local/bin/node]
3: 0x1000da0e2 node::(anonymous namespace)::ZlibStream::Init(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
4: 0x100242aaf v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) [/usr/local/bin/node]
5: 0x100241ff1 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(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: 0x100241690 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node]
7: 0x1c96c9adbe3d
Abort trap: 6
でもnpmのバージョンは> 5.5.1
になってる
$ npm -v
6.12.0
解決法
nodejsをインストールし直した。
バージョン管理ツール"n"を使ってたので、n上で削除→インストールした
$ n prune
$ n install lts
そうしたら無事にnpm installできた