mac上node版本和fsevents版本冲突

mac上node版本和fsevents版本

当node升级到12.0版本以上在进行npm install时会报错

以下是错误日志:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
../../../../nan/nan_converters_43_inl.h:22:1: warning: 'ToBoolean' is deprecated: ToBoolean can never throw. Use Local version. [-Wdeprecated-declarations]
X(Boolean)
^
../../../../nan/nan_converters_43_inl.h:18:12: note: expanded from macro 'X'
val->To ## TYPE(isolate->GetCurrentContext()) \\\n ^
<scratch space>:201:1: note: expanded from here
ToBoolean
^
/Users/rene/.node-gyp/12.1.0/include/node/v8.h:2523:3: note: 'ToBoolean' has been explicitly marked deprecated here
V8_DEPRECATE_SOON(\"ToBoolean can never throw. Use Local version.\",
^
/Users/rene/.node-gyp/12.1.0/include/node/v8config.h:322:29: note: expanded from macro 'V8_DEPRECATE_SOON'
declarator __attribute__((deprecated(message)))
^
In file included from ../fsevents.cc:6:
In file included from ../../../../nan/nan.h:221:
In file included from ../../../../nan/nan_converters.h:67:
../../../../nan/nan_converters_43_inl.h:40:1: warning: 'BooleanValue' is deprecated: BooleanValue can never throw. Use Isolate version. [-Wdeprecated-declarations]
X(bool, Boolean)
^
../../../../nan/nan_converters_43_inl.h:37:15: note: expanded from macro 'X'
return val->NAME ## Value(isolate->GetCurrentContext()); \\\n ^
<scratch space>:208:1: note: expanded from here
BooleanValue
^
/Users/rene/.node-gyp/12.1.0/include/node/v8.h:2561:3: note: 'BooleanValue' has been explicitly marked deprecated here
V8_DEPRECATED(\"BooleanValue can never throw. Use Isolate version.\",
^
/Users/rene/.node-gyp/12.1.0/include/node/v8config.h:307:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated(message)))
^
In file included from ../fsevents.cc:6:
In file included from ../../../../nan/nan.h:222:
In file included from ../../../../nan/nan_new.h:189:
../../../../nan/nan_implementation_12_inl.h:103:42: error: no viable conversion from 'v8::Isolate *' to 'Local<v8::Context>'
return scope.Escape(v8::Function::New( isolate
^~~~~~~
/Users/rene/.node-gyp/12.1.0/include/node/v8.h:183:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'v8::Isolate *' to 'const v8::Local<v8::Context> &' for 1st argument
class Local {
^
/Users/rene/.node-gyp/12.1.0/include/node/v8.h:183:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'v8::Isolate *' to 'v8::Local<v8::Context> &&' for 1st argument
/Users/rene/.node-gyp/12.1.0/include/node/v8.h:187:13: note: candidate template ignored: could not match 'Local<type-parameter-0-0>' against 'v8::Isolate *'
V8_INLINE Local(Local<S> that)
^
/Users/rene/.node-gyp/12.1.0/include/node/v8.h:4126:22: note: passing argument to parameter 'context' here
Local<Context> context, FunctionCallback callback,
^
In file included from ../fsevents.cc:6:
In file included from ../../../../nan/nan.h:222:
In file included from ../../../../nan/nan_new.h:189:
../../../../nan/nan_implementation_12_inl.h:337:37: error: too few arguments to function call, expected 2, have 1
return v8::StringObject::New(value).As<v8::StringObject>();
~~~~~~~~~~~~~~~~~~~~~ ^
/Users/rene/.node-gyp/12.1.0/include/node/v8.h:5380:3: note: 'New' declared here
static Local<Value> New(Isolate* isolate, Local<String> value);
^
In file included from ../fsevents.cc:6:
In file included from ../../../../nan/nan.h:222:
In file included from ../../../../nan/nan_new.h:189:
../../../../nan/nan_implementation_12_inl.h:337:58: error: expected '(' for function-style cast or type construction
return v8::StringObject::New(value).As<v8::StringObject>();
~~~~~~~~~~~~~~~~^
../../../../nan/nan_implementation_12_inl.h:337:60: error: expected expression
return v8::StringObject::New(value).As<v8::StringObject>();
^
In file included from ../fsevents.cc:6:
../../../../nan/nan.h:1063:44: error: no matching member function for call to 'ToString'
v8::Local<v8::String> string = from->ToString();
~~~~~~^~~~~~~~
/Users/rene/.node-gyp/12.1.0/include/node/v8.h:2528:44: note: candidate function not viable: requires single argument 'context', but no arguments were provided
V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
^
/Users/rene/.node-gyp/12.1.0/include/node/v8.h:2544:35: note: candidate function not viable: requires single argument 'isolate', but no arguments were provided
Local<String> ToString(Isolate* isolate) const);
^
In file included from ../fsevents.cc:6:
...

解决方法如下:
1
2
3
4
删除node_moules文件夹
删除package-lock.json文件
安装最新版本的 fsevents: npm i fsevents -D
然后重新安装依赖 npm i
或者降级node版本到4.0版本
fsevents的github项目已经写清楚
  1. v2 supports node 8.16+
  2. v1.2.8 supports node 6+
  3. v1.2.7 supports node 4+