错误:'REPLACE_INVALID_UTF8'不是'v8 :: String'的成员

所以我想在Raspbian中构build这个nodejs工具 。 所以作为说明说我需要npm install我继续前进,安装节点与apt-get:

 sudo apt-get install nodejs npm 

然后我尝试编译/安装,我得到这个错误:

 $ npm install > configure@0.0.1 install /home/pi/Documents/Code/buzzerbot9000/node_modules/configure > node install.js sh: 1: node: not found npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian npm ERR! configure@0.0.1 install: `node install.js` npm ERR! Exit status 127 

显然,nodejs软件包的安装并没有创build任何可用的全局node命令。 然后我通过apt-file来查找它:

 $ apt-file search /usr/bin/node clustershell: /usr/bin/nodeset genders: /usr/bin/nodeattr lbdb: /usr/bin/nodelist2lbdb node-gyp: /usr/bin/node-gyp node-static: /usr/bin/node-static nodejs: /usr/bin/nodejs nodejs-dbg: /usr/lib/debug/usr/bin/nodejs nodejs-legacy: /usr/bin/node noweb: /usr/bin/nodefs osm2pgsql: /usr/bin/nodecachefilereader 

所以,我想我需要安装nodejs-legacy ,我这样做,我得到重要的错误在这里突出显示:

 $ npm install - > configure@0.0.1 install /home/pi/Documents/Code/buzzerbot9000/node_modules/configure > node install.js - > sqlite3@3.1.0 install /home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3 > node-pre-gyp install --fallback-to-build make: Entering directory '/home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3/build' ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3081101/sqlite3.c TOUCH Release/obj.target/deps/action_before_build.stamp CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3081101/sqlite3.o AR(target) Release/obj.target/deps/sqlite3.a COPY Release/sqlite3.a CXX(target) Release/obj.target/node_sqlite3/src/database.o In file included from ../src/database.h:10:0, from ../src/database.cc:4: ../node_modules/nan/nan.h:316:47: error: 'REPLACE_INVALID_UTF8' is not a member of 'v8::String' static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8; ^ node_sqlite3.target.mk:98: recipe for target 'Release/obj.target/node_sqlite3/src/database.o' failed make: *** [Release/obj.target/node_sqlite3/src/database.o] Error 1 make: Leaving directory '/home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3/build' gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23) gyp ERR! stack at ChildProcess.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:809:12) gyp ERR! System Linux 4.1.7-v7+ gyp ERR! command "nodejs" "/usr/bin/node-gyp" "build" "--fallback-to-build" "--module=/home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3/lib/binding/node-v11-linux-arm/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3/lib/binding/node-v11-linux-arm" gyp ERR! cwd /home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3 gyp ERR! node -v v0.10.29 gyp ERR! node-gyp -v v0.12.2 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp build --fallback-to-build --module=/home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3/lib/binding/node-v11-linux-arm/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3/lib/binding/node-v11-linux-arm' (1) node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js:83:29) node-pre-gyp ERR! stack at ChildProcess.emit (events.js:98:17) node-pre-gyp ERR! stack at maybeClose (child_process.js:755:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:822:5) node-pre-gyp ERR! System Linux 4.1.7-v7+ node-pre-gyp ERR! command "node" "/home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd /home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3 node-pre-gyp ERR! node -v v0.10.29 node-pre-gyp ERR! node-pre-gyp -v v0.6.10 node-pre-gyp ERR! not ok Failed to execute 'node-gyp build --fallback-to-build --module=/home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3/lib/binding/node-v11-linux-arm/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/pi/Documents/Code/buzzerbot9000/node_modules/sqlite3/lib/binding/node-v11-linux-arm' (1) npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian npm ERR! sqlite3@3.1.0 install: `node-pre-gyp install --fallback-to-build` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the sqlite3@3.1.0 install script. npm ERR! This is most likely a problem with the sqlite3 package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-pre-gyp install --fallback-to-build npm ERR! You can get their info via: npm ERR! npm owner ls sqlite3 npm ERR! There is likely additional logging output above. npm ERR! System Linux 4.1.7-v7+ npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" npm ERR! cwd /home/pi/Documents/Code/buzzerbot9000 npm ERR! node -v v0.10.29 npm ERR! npm -v 1.4.21 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /home/pi/Documents/Code/buzzerbot9000/npm-debug.log npm ERR! not ok code 0 

我已经为此search,显然这是因为有一个旧版本的东西(见例如这个问题 )。

那么,我应该怎样在这里升级,以什么方式(我应该先卸载debian软件包并使用npm?我迷路了)。 请解释它像一个5岁,因为我是新的节点。

显然Debian从v0.10.29中缺less了一个补丁,因为v0.10.29有这个常量。 最好的方法就是使用一个来自官方的源代码,而不是使用NodeSource的repos 。

另外值得注意的是:在本文中,node v4.x是最新的稳定版本。

我们刚刚通过以下方式解决了这个问题:

 npm -g install npm 

只要尝试更新npm。