可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I was initially getting this error as a dependency for a different package, but it fails when I try it on its own too. Since it's the first time I'm trying to install a node.js package, I'm sure I'm missing something, but what?
$ npm install --save sse4_crc32 \ > sse4_crc32@3.3.0 install /home/agam/node_modules/sse4_crc32 > node-gyp rebuild make: Entering directory '/home/agam/node_modules/sse4_crc32/build' CXX(target) Release/obj.target/sse4_crc32/src/sse4_crc32.o In file included from ../src/sse4_crc32.cpp:18:0: ../node_modules/nan/nan.h: In constructor ‘Nan::Utf8String::Utf8String(v8::Local)’: ../node_modules/nan/nan.h:1178:27: error: ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’ v8::String::REPLACE_INVALID_UTF8; ^ sse4_crc32.target.mk:87: recipe for target 'Release/obj.target/sse4_crc32/src/sse4_crc32.o' failed make: *** [Release/obj.target/sse4_crc32/src/sse4_crc32.o] Error 1 make: Leaving directory '/home/agam/node_modules/sse4_crc32/build'
回答1:
Ran into the same issue today.
I was on Node 0.10.29 which supposedly should work. Upgraded to Node 0.10.38 but that didn't solve the problem.
I was running on debian (jessy) and there npm was installed pulling in a old version of node-gyp as a dependency. 0.2.0 I believe for npm 1.4.x.
Installing a new version of node-gyp through npm install -g solved the problem. (After some symlink changes to point to the new node-gyp).
回答2:
My guess is you're using node v0.11.12 or an earlier v0.11 release which would not have v8::String::REPLACE_INVALID_UTF8
(which is available since v0.11.13 when v8 was upgraded to 3.24.x from 3.22.x). node v0.11.x versions are considered unstable and you should upgrade to at least v0.12. After that, the error should go away.
The more technical reason for the error is that nan
simply does a check if the node ABI version is post-v0.10 around the code that uses v8::String::REPLACE_INVALID_UTF8
, so it assumes you're using v0.12 or newer, where that constant is available.