节点版本 v4.0.0 npm 版本 v2.14.2
我尝试安装 node-pre-gyp 和 node-gyp,它们似乎安装得很好。我还尝试安装特定的串口 v1.7.4 版本。我也尝试添加不安全的烫发。安装串口时都不起作用
跑步时
sudo npm install serialport --unsafe-perm
我收到以下错误。我认为这可能是因为我的 c++ 编译器已过时,并且 node 正在尝试安装不兼容的 node-pre-gyp。我都不确定这是什么问题以及如何解决它。
node-pre-gyp ERR! Tried to download(404): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v46-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for serialport@4.0.7 and node@4.0.0 (node-v46 ABI) (falling back to source compile with node-gyp)
make: Entering directory '/home/pi/node_modules/serialport/build'
CXX(target) Release/obj.target/serialport/src/serialport.o
In file included from ../src/./serialport.h:7:0,
from ../src/serialport.cpp:1:
../node_modules/nan/nan.h:43:3: error: #error This version of node/NAN/v8 requires a C++11 compiler
In file included from /root/.node-gyp/4.0.0/include/node/node.h:42:0,
from ../node_modules/nan/nan.h:47,
from ../src/./serialport.h:7,
from ../src/serialport.cpp:1:
/root/.node-gyp/4.0.0/include/node/v8.h:336:1: error: expected unqualified-id before ‘using’
/root/.node-gyp/4.0.0/include/node/v8.h:469:1: error: expected unqualified-id before ‘using’
/root/.node-gyp/4.0.0/include/node/v8.h:852:1: error: expected unqualified-id before ‘using’
In file included from ../node_modules/nan/nan.h:190:0,
from ../src/./serialport.h:7,
from ../src/serialport.cpp:1:
../node_modules/nan/nan_new.h:225:1: note: template<class T, class A0, class A1, class A2, class A3> typename Nan::imp::Factory<T>::return_t Nan::New(A0, A1, A2, A3)
../node_modules/nan/nan_new.h:237:1: note: template<class T> typename Nan::imp::Factory::return_t Nan::New(Nan::FunctionCallback, v8::Local<v8::Value>)
../node_modules/nan/nan_new.h:245:1: note: template<class T, class A2> typename Nan::imp::Factory<T>::return_t Nan::New(Nan::FunctionCallback, v8::Local<v8::Value>, A2)
../src/serialport.cpp: At global scope:
../src/serialport.cpp:653:17: error: variable or field ‘init’ declared void
../src/serialport.cpp:653:13: error: ‘Handle’ is not a member of ‘v8’
../src/serialport.cpp:653:34: error: expected primary-expression before ‘>’ token
../src/serialport.cpp:653:36: error: ‘target’ was not declared in this scope
../src/serialport.cpp:670:1: error: ‘init’ was not declared in this scope
../node_modules/nan/nan_new.h: In function ‘v8::Local<T> Nan::imp::To(v8::Local<v8::Integer>) [with T = v8::Int32]’:
../node_modules/nan/nan_new.h:29:1: warning: control reaches end of non-void function [-Wreturn-type]
../src/serialport.cpp: In function ‘v8::Local<v8::Value> getValueFromObject(v8::Local<v8::Object>, std::string)’:
../src/serialport.cpp:87:1: warning: control reaches end of non-void function [-Wreturn-type]
serialport.target.mk:96: recipe for target 'Release/obj.target/serialport/src/serialport.o' failed
make: *** [Release/obj.target/serialport/src/serialport.o] Error 1
make: Leaving directory '/home/pi/node_modules/serialport/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/pi/node_modules/node-gyp/lib/build.js:285:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.1.19-v7+
gyp ERR! command "/usr/local/bin/node" "/home/pi/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/pi/node_modules/serialport/build/Release/serialport.node" "--module_name=serialport" "--module_path=/home/pi/node_modules/serialport/build/Release"
gyp ERR! cwd /home/pi/node_modules/serialport
gyp ERR! node -v v4.0.0
gyp ERR! node-gyp -v v3.6.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /home/pi/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/pi/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/home/pi/node_modules/serialport/build/Release' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/pi/node_modules/serialport/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:817:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Linux 4.1.19-v7+
node-pre-gyp ERR! command "/usr/local/bin/node" "/home/pi/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/pi/node_modules/serialport
node-pre-gyp ERR! node -v v4.0.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /home/pi/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/pi/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/home/pi/node_modules/serialport/build/Release' (1)
npm ERR! Linux 4.1.19-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "serialport" "--unsafe-perm"
npm ERR! node v4.0.0
npm ERR! npm v2.14.2
npm ERR! code ELIFECYCLE
npm ERR! serialport@4.0.7 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@4.0.7 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the serialport 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 serialport
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/pi/Desktop/QuadLink/npm-debug.log