错误:'REPLACE_INVALID_UTF8'不是'v8 :: String'

时间:2015-10-12 23:45:23

标签: node.js npm raspbian raspberry-pi2 node-gyp

所以我想在Raspbian中构建this nodejs tool。所以说明我需要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包的安装并没有创建全局可用的任何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

我已经用Google搜索了,显然这是因为有旧版本的东西(例如参见this other question)。

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

2 个答案:

答案 0 :(得分:1)

显然Debian缺少v0.10.29的补丁,因为v0.10.29有这个常量。从官方来源获取最新信息的最佳选择是使用NodeSource's repos之一。

另外值得注意的是:截至本文撰写时,node v4.x是最新的稳定版本。

答案 1 :(得分:1)

我们刚刚解决了以下问题:

npm -g install npm

尝试更新npm。