Mac node-sass 安装失败“v8::String::Utf8Value”

Posted mr_raptor

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mac node-sass 安装失败“v8::String::Utf8Value”相关的知识,希望对你有一定的参考价值。

基本报错

../src/create_string.cpp:17:25: error: no matching constructor for initialization of 'v8::String::Utf8Value'
  v8::String::Utf8Value string(value);
                        ^      ~~~~~
/Users/hongsen.ren/.node-gyp/12.1.0/include/node/v8.h:3002:5: note: candidate constructor not viable: no known
      conversion from 'v8::Local<v8::Value>' to 'const v8::String::Utf8Value' for 1st argument
    Utf8Value(const Utf8Value&) = delete;
    ^
/Users/hongsen.ren/.node-gyp/12.1.0/include/node/v8.h:2995:5: note: candidate constructor not viable: requires
      2 arguments, but 1 was provided
    Utf8Value(Isolate* isolate, Local<v8::Value> obj);
    ^
1 error generated.
make: *** [Release/obj.target/binding/src/create_string.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/hongsen.ren/code/bk_cmdb/bk-cmdb/src/ui/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:196:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:256:12)
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/Cellar/node/12.1.0/bin/node" "/Users/hongsen.ren/code/bk_cmdb/bk-cmdb/src/ui/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/hongsen.ren/code/bk_cmdb/bk-cmdb/src/ui/node_modules/node-sass
gyp ERR! node -v v12.1.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1

其实很简单,根据node和npm的版本指定要安装的node-sass版本

System Darwin 18.6.0
node -v v12.1.0
node-gyp -v v3.8.0
npm -v 6.9.0

最终安装成功

npm install node-sass@4.12.0

以上是关于Mac node-sass 安装失败“v8::String::Utf8Value”的主要内容,如果未能解决你的问题,请参考以下文章

Mac node-sass 安装失败“v8::String::Utf8Value”

node-sass 安装失败的解决措施

node-sass安装失败解决方法

关于node-sass安装失败的解决办法

`sass-loader` 需要 `node-sass` >=4。请安装兼容版本

node-sass安装失败之npm ERR! Failed at the node-sass@4.12.0 postinstall script.