Author Topic: Can't install Pi Gateway: nconf and serialport dependencies fail [solved]  (Read 4622 times)

brandock

  • NewMember
  • *
  • Posts: 31
I recently tried installing MQTT on my Pi Gateway for a project I am working on. After installation I am unable to run gateway.js. I get this error.

Code: [Select]
pi@raspberrypi:~/gateway $ node gateway.js &
[1] 1858
pi@raspberrypi:~/gateway $ module.js:549
    throw err;
    ^

Error: Cannot find module '/home/pi/gateway/node_modules/serialport/build/Release/node-v57-linux-arm/serialport.node'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/pi/gateway/node_modules/serialport/serialport.js:14:25)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

I found this note from Felix from a long time ago.

Serialport might be a tricky one because of mismatching versions. Not really sure if the creator keeps it up to date or if the Pi repositories keep a good version, I had troubles with that too and had to install a specific node version that ended up accepting serialport, I included a short script which can check for you if serialport installed correctly.

I haven't been able to get things running again. I tried removing node_modules and doing npm install to see if things would rebuild correctly. No luck.

Any suggestions?
« Last Edit: August 02, 2018, 11:23:24 AM by Felix »

brandock

  • NewMember
  • *
  • Posts: 31
Update: Tried the following:
Start over with NOOBS. I used the full Stretch version, not Stretch Lite, but should this matter?
Then ran sudo wget https://raw.githubusercontent.com/LowPowerLab/RaspberryPi-Gateway/master/.setup/gatewaysetup.sh
Then sudo bash gatewaysetup.sh && sudo rm gatewaysetup.sh
Got the forever Waiting for socket connection ...

So I tried manually running gateway.js, and it appears nconf is missing.


Code: [Select]
[code]pi@raspberrypi:~/gateway $ node gateway.js &
[1] 4739
pi@raspberrypi:~/gateway $ module.js:549
    throw err;
    ^

Error: Cannot find module 'nconf'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/pi/gateway/gateway.js:30:13)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

So then I decided to try getting the dependencies by doing "npm install" from the gateway directory. (I had to first install npm: "sudo apt-get install npm".)

Now I get the failure that seems to be the inability to correctly compile the serialport module, which is where I began.

Code: [Select]
pm ERR! serialport@2.0.6 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@2.0.6 install script.
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! System Linux 4.14.50-v7+
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/pi/gateway
npm ERR! node -v v8.11.1
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/gateway/npm-debug.log
npm ERR! not ok code 0



brandock

  • NewMember
  • *
  • Posts: 31
Another update: It appears the gatewaysetup.sh script is not installing npm. Here is a portion of the output, just after it installs node.js.

Code: [Select]
************* STEP: Setup Gateway app & dependencies *************
Initialized empty Git repository in /home/pi/gateway/.git/
remote: Counting objects: 1747, done.
remote: Total 1747 (delta 1), reused 1 (delta 1), pack-reused 1745
Receiving objects: 100% (1747/1747), 9.80 MiB | 3.29 MiB/s, done.
Resolving deltas: 100% (377/377), done.
From https://github.com/LowPowerLab/RaspberryPi-Gateway
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
sudo: npm: command not found
sudo: npm: command not found
************* STEP: Create self signed HTTPS certificate (5 year) *************

Specifics of my setup:
Raspberry Pi 3 Model B+
In my latest attempt I used PiBakery to install Stretch Lite as described in the guide.


rd909

  • NewMember
  • *
  • Posts: 18
  • Country: us
FWIW, I stuck in the same spot. New raspbian stretch install (had sdcard corruption, so starting over), and I can't get serialport to install.

Code: [Select]
pi@gateway:/mnt/gateway $ sudo npm install --unsafe-perm --build-from-source
(node:26209) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

> RaspberryPi-Gateway@8.10.0 preinstall /mnt/gateway
>

npm WARN deprecated nodemailer@1.10.0: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
npm WARN deprecated mailcomposer@2.1.0: This project is unmaintained
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated buildmail@2.0.0: This project is unmaintained
npm WARN package.json node-pre-gyp@0.6.18 license should be a valid SPDX license expression
|
> serialport@2.0.6 install /mnt/gateway/node_modules/serialport
> node-pre-gyp install --fallback-to-build

make: Entering directory '/mnt/gateway/node_modules/serialport/build'
make: Warning: File 'serialport.target.mk' has modification time 1451 s in the future
  CXX(target) Release/obj.target/serialport/src/serialport.o
In file included from ../node_modules/nan/nan.h:182:0,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
../node_modules/nan/nan_maybe_43_inl.h: In function ‘Nan::MaybeLocal<v8::Object> Nan::CloneElementAt(v8::Local<v8::Array>, uint32_t)’:
../node_modules/nan/nan_maybe_43_inl.h:221:58: warning: ‘v8::MaybeLocal<v8::Object> v8::Array::CloneElementAt(v8::Local<v8::Context>, uint32_t)’ is deprecated: Cloning is not supported. [-Wdeprecated-declarations]
   return array->CloneElementAt(GetCurrentContext(), index);
                                                          ^
In file included from /usr/include/nodejs/deps/v8/include/v8.h:26:0,
                 from /usr/include/nodejs/src/node.h:63,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:3517:36: note: declared here
                 MaybeLocal<Object> CloneElementAt(Local<Context> context,
                                    ^
/usr/include/nodejs/deps/v8/include/v8config.h:318:3: note: in definition of macro ‘V8_DEPRECATED’
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
In file included from ../node_modules/nan/nan_new.h:189:0,
                 from ../node_modules/nan/nan.h:188,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
../node_modules/nan/nan_implementation_12_inl.h: In static member function ‘static Nan::imp::FactoryBase<v8::BooleanObject>::return_t Nan::imp::Factory<v8::BooleanObject>::New(bool)’:
../node_modules/nan/nan_implementation_12_inl.h:40:38: warning: ‘static v8::Local<v8::Value> v8::BooleanObject::New(bool)’ is deprecated: Pass an isolate [-Wdeprecated-declarations]
   return v8::BooleanObject::New(value).As<v8::BooleanObject>();
                                      ^
In file included from /usr/include/nodejs/deps/v8/include/v8.h:26:0,
                 from /usr/include/nodejs/src/node.h:63,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:4845:56: note: declared here
   V8_DEPRECATED("Pass an isolate", static Local<Value> New(bool value));
                                                        ^
/usr/include/nodejs/deps/v8/include/v8config.h:318:3: note: in definition of macro ‘V8_DEPRECATED’
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
In file included from ../src/serialport.h:5:0,
                 from ../src/serialport.cpp:3:
../node_modules/nan/nan.h: At global scope:
../node_modules/nan/nan.h:590:20: error: variable or field ‘AddGCEpilogueCallback’ declared void
       v8::Isolate::GCEpilogueCallback callback
                    ^~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:590:7: error: ‘GCEpilogueCallback’ is not a member of ‘v8::Isolate’
       v8::Isolate::GCEpilogueCallback callback
       ^~
../node_modules/nan/nan.h:591:18: error: expected primary-expression before ‘gc_type_filter’
     , v8::GCType gc_type_filter = v8::kGCTypeAll) {
                  ^~~~~~~~~~~~~~
../node_modules/nan/nan.h:596:20: error: variable or field ‘RemoveGCEpilogueCallback’ declared void
       v8::Isolate::GCEpilogueCallback callback) {
                    ^~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:596:7: error: ‘GCEpilogueCallback’ is not a member of ‘v8::Isolate’
       v8::Isolate::GCEpilogueCallback callback) {
       ^~
../node_modules/nan/nan.h:601:20: error: variable or field ‘AddGCPrologueCallback’ declared void
       v8::Isolate::GCPrologueCallback callback
                    ^~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:601:7: error: ‘GCPrologueCallback’ is not a member of ‘v8::Isolate’
       v8::Isolate::GCPrologueCallback callback
       ^~
../node_modules/nan/nan.h:602:18: error: expected primary-expression before ‘gc_type_filter’
     , v8::GCType gc_type_filter = v8::kGCTypeAll) {
                  ^~~~~~~~~~~~~~
../node_modules/nan/nan.h:607:20: error: variable or field ‘RemoveGCPrologueCallback’ declared void
       v8::Isolate::GCPrologueCallback callback) {
                    ^~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:607:7: error: ‘GCPrologueCallback’ is not a member of ‘v8::Isolate’
       v8::Isolate::GCPrologueCallback callback) {
       ^~
../node_modules/nan/nan.h: In function ‘bool Nan::SetAccessor(v8::Local<v8::Object>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute)’:
../node_modules/nan/nan.h:1933:16: warning: ‘bool v8::Object::SetAccessor(v8::Local<v8::Name>, v8::AccessorNameGetterCallback, v8::AccessorNameSetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
     , attribute);
                ^
In file included from /usr/include/nodejs/deps/v8/include/v8.h:26:0,
                 from /usr/include/nodejs/src/node.h:63,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:3187:22: note: declared here
                 bool SetAccessor(Local<Name> name,
                      ^
/usr/include/nodejs/deps/v8/include/v8config.h:318:3: note: in definition of macro ‘V8_DEPRECATED’
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Open(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:115:116: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   baton->baudRate = Nan::Get(options, Nan::New<v8::String>("baudRate").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
                                                                                                                    ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp:116:116: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   baton->dataBits = Nan::Get(options, Nan::New<v8::String>("dataBits").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
                                                                                                                    ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp:117:120: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   baton->bufferSize = Nan::Get(options, Nan::New<v8::String>("bufferSize").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
                                                                                                                        ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp:119:131: warning: ‘v8::Local<v8::Number> v8::Value::ToNumber() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   baton->stopBits = ToStopBitEnum(Nan::Get(options, Nan::New<v8::String>("stopBits").ToLocalChecked()).ToLocalChecked()->ToNumber()->NumberValue());
                                                                                                                                   ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9760:15: note: declared here
 Local<Number> Value::ToNumber() const {
               ^~~~~
../src/serialport.cpp: In function ‘void EIO_AfterOpen(uv_work_t*)’:
../src/serialport.cpp:159:31: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
     int fd = argv[1]->ToInt32()->Int32Value();
                               ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Update(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:180:29: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   int fd = info[0]->ToInt32()->Int32Value();
                             ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp:199:116: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   baton->baudRate = Nan::Get(options, Nan::New<v8::String>("baudRate").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
                                                                                                                    ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp:200:116: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   baton->dataBits = Nan::Get(options, Nan::New<v8::String>("dataBits").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
                                                                                                                    ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp:201:120: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   baton->bufferSize = Nan::Get(options, Nan::New<v8::String>("bufferSize").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
                                                                                                                        ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp:203:131: warning: ‘v8::Local<v8::Number> v8::Value::ToNumber() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   baton->stopBits = ToStopBitEnum(Nan::Get(options, Nan::New<v8::String>("stopBits").ToLocalChecked()).ToLocalChecked()->ToNumber()->NumberValue());
                                                                                                                                   ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9760:15: note: declared here
 Local<Number> Value::ToNumber() const {
               ^~~~~
../src/serialport.cpp: In function ‘void EIO_AfterUpdate(uv_work_t*)’:
../src/serialport.cpp:242:31: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
     int fd = argv[1]->ToInt32()->Int32Value();
                               ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Write(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:263:29: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   int fd = info[0]->ToInt32()->Int32Value();
                             ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Close(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:374:29: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   int fd = info[0]->ToInt32()->Int32Value();
                             ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Flush(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:493:29: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   int fd = info[0]->ToInt32()->Int32Value();
                             ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Set(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:542:29: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   int fd = info[0]->ToInt32()->Int32Value();
                             ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Drain(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:603:29: warning: ‘v8::Local<v8::Int32> v8::Value::ToInt32() const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   int fd = info[0]->ToInt32()->Int32Value();
                             ^
In file included from /usr/include/nodejs/src/node.h:63:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/serialport.h:5,
                 from ../src/serialport.cpp:3:
/usr/include/nodejs/deps/v8/include/v8.h:9796:14: note: declared here
 Local<Int32> Value::ToInt32() const {
              ^~~~~
serialport.target.mk:95: recipe for target 'Release/obj.target/serialport/src/serialport.o' failed
make: *** [Release/obj.target/serialport/src/serialport.o] Error 1
make: Leaving directory '/mnt/gateway/node_modules/serialport/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:276:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.14.52-v7+
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "build" "--fallback-to-build" "--module=/mnt/gateway/node_modules/serialport/build/Release/node-v57-linux-arm/serialport.node" "--module_name=serialport" "--module_path=/mnt/gateway/node_modules/serialport/build/Release/node-v57-linux-arm"
gyp ERR! cwd /mnt/gateway/node_modules/serialport
gyp ERR! node -v v8.11.1
gyp ERR! node-gyp -v v3.4.0
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=/mnt/gateway/node_modules/serialport/build/Release/node-v57-linux-arm/serialport.node --module_name=serialport --module_path=/mnt/gateway/node_modules/serialport/build/Release/node-v57-linux-arm' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/mnt/gateway/node_modules/serialport/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Linux 4.14.52-v7+
node-pre-gyp ERR! command "/usr/bin/node" "/mnt/gateway/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /mnt/gateway/node_modules/serialport
node-pre-gyp ERR! node -v v8.11.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.18
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp build --fallback-to-build --module=/mnt/gateway/node_modules/serialport/build/Release/node-v57-linux-arm/serialport.node --module_name=serialport --module_path=/mnt/gateway/node_modules/serialport/build/Release/node-v57-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! serialport@2.0.6 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@2.0.6 install script.
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! System Linux 4.14.52-v7+
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "--unsafe-perm" "--build-from-source"
npm ERR! cwd /mnt/gateway
npm ERR! node -v v8.11.1
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /mnt/gateway/npm-debug.log
npm ERR! not ok code 0

pi@gateway:/mnt/gateway $ npm -v
-bash: /usr/local/bin/npm: No such file or directory
pi@gateway:/mnt/gateway $ /usr/bin/npm -v
1.4.21
(node:26584) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
pi@gateway:/mnt/gateway $ nodejs -v
v8.11.1


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Guys,
Thanks for reporting this,
I will have to find some time to look into this.
AFAIK the install has been working flawlessly so far.

FOLLOW-UP QUESTION for brandock - I saw another post from you where you report things are going OK, was this happening only AFTER installing MQTT?
« Last Edit: July 23, 2018, 11:58:29 AM by Felix »

brandock

  • NewMember
  • *
  • Posts: 31
FOLLOW-UP QUESTION for brandock - I saw another post from you where you report things are going OK
In the other post I was trying to figure out why my serial data wasn't creating nodes in gateway.js. I realized that I needed to define user metrics in the userMetrics folder that matched the data I was sending. I'll update that post to be more specific. So that was working fine. But I decided to change tactics ...

... was this happening only AFTER installing MQTT?

So I decided that I wanted to change tactics and use a standard Pi Gateway with MQTT. I think the RFM69 libary is very cool, and has real advantages over JeeLib with the encryption, the auto-RSSI, the wireless programming. So I thought, "What if I use the Moteino Pi Gateway in standard factory configuration, but when needed I can use an Event to communicate via MQTT to my emonPi/emonCMS setup." It turns out this works really well. I will write it up.

But yes, this was when my problems started, which I was just able to resolve yesterday.

Somewhere along the line while I was using npm to install mqtt, I ended up with version incompatiblity issues. I think one of the commands I ran pushed Node.js to the current version.

Anyway, I decided, "no problem. I'll start from scratch."

Well, it turns out there is currently a problem with starting from scratch and it comes from these lines in the gatewaysetup.sh script:
Code: [Select]
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -;
sudo apt-get -y install nodejs;

I don't have another available Pi to try this out on, but on a Pi 3 B+ this will fail, and node 4.x will not be installed. I kept trying to rectify things manually after the setup script (mainly by going to the gateway directory and typing "npm install") and I'd end up with node version 8.x, and serialport won't compile with that version.

You can see in both my pasted-in logs and those pasted in by rd909: gyp ERR! node -v v8.11.1

So here is how I installed my working Pi Gateway, from the write-up I made for myself so I would remember:

Start with PiBakery installing Stretch Lite.

The script that installs the Pi Gateway currently has a problem installing the necessary version of Node.js. So first use nvm to install a 4.x version.
Code: [Select]
sudo wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
nvm install 4.4.3
You can see that it worked by typing nvm list.
Code: [Select]
pi@raspberrypi3:~ $ nvm list
->       v4.4.3
default -> 4.4.3 (-> v4.4.3)
node -> stable (-> v4.4.3) (default)
stable -> 4.4 (-> v4.4.3) (default)
iojs -> N/A (default)
Now get the script but don’t yet run it.
Code: [Select]
cd /home/pi
sudo wget https://raw.githubusercontent.com/LowPowerLab/RaspberryPi-Gateway/master/.setup/gatewaysetup.sh

Now stop! Don’t run the setup script without editing it. Use “nano gatewaysetup.sh”. Comment out these three lines:
Code: [Select]
#else
#  curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -;
#  sudo apt-get -y install nodejs;

Now it is safe to do the next step and run the script.
Code: [Select]
sudo bash gatewaysetup.sh && sudo rm gatewaysetup.sh

Now you can update that dependencies in the gateway directory.
Code: [Select]
cd gateway
npm install

I also had to use the nvm path to node to start gateway.js.
Code: [Select]
pi@raspberrypi3:~/gateway $ which node
/home/pi/.nvm/versions/node/v4.4.3/bin/node
Edit this file:
Code: [Select]
sudo nano /etc/systemd/system/gateway.service
And use the result of “which node” to replace /usr/bin/none in the startup command.
Code: [Select]
ExecStart=/bin/sh -c '/home/pi/.nvm/versions/node/v4.4.3/bin/node /home/pi/gateway/gateway.js >> /home/pi/gateway/logs/gateway.sys.log 2>&1'

Reboot.




bpr

  • NewMember
  • *
  • Posts: 9
  • Country: us
I really appreciate all the work put into the Moteino Pi Gateway, but the use of old node and serialport versions is a bit of a concern. In order to help prevent possible version mismatches with other evolving software, I've been working on upgrading the gateway to the more current versions of node (8.11.3) and serialport (6.2.1). Turns out it's not too difficult, although I've only done this on a fresh raspian setup, not as a update to existing gateway installation:

**Assuming a RPi3**
-fresh updated raspian stretch

-git clone Moteino Gateway
pi@raspberrypi:~ $ git clone https://github.com/LowPowerLab/RaspberryPi-Gateway.git gateway

-edit gateway.js, package.json, and /home/pi/.setup/gatewaysetup.sh as follows:
-In package.json: change the serialport version to the current "6.2.1"
-In gatewaysetup.sh: change NODEDIR to '/usr/bin/node',
   and curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - (from 4.x)
   and  sudo npm cache clean to sudo npm cache verify
-In gateway.js: Replace the line: serial = new serialport.SerialPort(....  with the following lines:
   var port = new SerialPort(settings.serial.port.value, {baudRate : settings.serial.baud.value});
   var Readline = SerialPort.parsers.Readline;
   var parser = new Readline();
   port.pipe(parser);
-Also in gateway.js:
   //serial.on('error', function serialErrorHandler(error) { is replaced by
   port.on('error', function serialErrorHandler(error) {
   
   //serial.on('close', function serialCloseHandler(error) { is replaced by
   port.on('close', function serialCloseHandler(error) {   

   //serial.on("data", function(data) { processSerialData(data); }); is replaced by
   parser.on("data", function(data) { processSerialData(data); });

   //serial.open();  replaced by
   port.open();

   Later in gateway.js, replace the three instances of serial.write(... with port.write(...
   
cd ~/gateway

cp /home/pi/gateway/.setup/gatewaysetup.sh /home/pi/gateway/gatewaysetup.sh then sudo bash gatewaysetup.sh

-change enable_uart=0 to enable_uart=1 in /boot/config.txt (for RPi3)

-add dtoverlay=pi3-disable-bt to end of /boot/config.txt (for RPi3)
 
-reboot

It's working well for me utilizing a USBMoteino plugged into the RPi3. I'll eventually get around to replacing the USBMoteino with the Mightyhat I've been running on my older installation. If these changes help anyone, I'll be happy.
« Last Edit: July 30, 2018, 04:30:03 PM by Felix »

rd909

  • NewMember
  • *
  • Posts: 18
  • Country: us
Thanks brandock, I was able to get it mostly working with your tips. Current version of serialport, nodejs, etc. I had to make a few modifications though:

I commented out the git commands in gatewaysetup.sh since you already did that, and modified gateway.js, which would be overwritten if you the pulled it again (I think).

Also in gateway.js I did this:

Code: [Select]
//serial = new serialport.SerialPort(settings.serial.port.value, { baudrate : settings.serial.baud.value, parser: serialport.parsers.readline("\n") }, false);
var Readline = serialport.parsers.Readline;
var parser = new Readline();
var port = new serialport(settings.serial.port.value, {baudRate : settings.serial.baud.value, parser: new serialport.parsers.Readline("\n")}, false);
port.pipe(parser);

Note that “serialport” is all lower case. I also added the parser, but I am not sure if it is really required.

You also mention replacing serial.write with port.write, and there are instances of serial.drain that need to be changed to port.drain as well.

I had a hell of a time getting the Bluetooth /dev/ttyAMA0 straightened out with the mightyhat again, but I think that if people would just change the port to /dev/serial0 in the settings.json5 on a rpi3 with Stretch that it would work. In the end I used

Code: [Select]
enable_uart=1
dtoverlay=pi3-disable-bt

In /boot/config.txt and set the port to /dev/serial0 anyway, because I think mightyhat expects a baud rate of 115200 and I don’t think you can get that on the /dev/ttyS0. Anyway, I got it working but it was a pain. Thanks for the help.
« Last Edit: July 30, 2018, 03:11:35 PM by Felix »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
I made some changes and updated the install script, as well as updated deprecated packages.
It works great with Pi3.

Can you guys run the install from scratch and report if it works (along with Pi variant)?

You still need to take care of the serialport/bluetooth, and setup any stuff like SSH etc if you run from a fresh image.
« Last Edit: July 30, 2018, 05:25:58 PM by Felix »

bpr

  • NewMember
  • *
  • Posts: 9
  • Country: us
Just finished fresh install of your updated installer on stretch 4.14.52-v7+ 6-27 on a RPI 3 Model B Rev 1.2 and it works flawlessly. Thanks, Felix!
There are some "high level vulnerabilties" and some deprecated warnings in some of the installed secondary node modules that I dpn't think I use but the messages went by so fast and I can't retrieve them anywhere - my main concerns were node.js and serialport versions not the mailer or other similar things (not entirely sure WHICH modules).
Thanks again for the fast update! Works like a charm
« Last Edit: July 30, 2018, 09:23:18 PM by bpr »

bpr

  • NewMember
  • *
  • Posts: 9
  • Country: us
Ok, after further testing of the brand new Gateway install, I have some quibbles, but nothing I probably can't work around. Other than those, working great!
Quibbles:
1) I had been using the node module "rpi-gpio" in a earlier installation of gateway.js so I could receive commands from a LINX keyfob (because you haven't created a moteino keyfob... yet? and my attempt at same was too big) to interact with a DIY home alarm system and it seems that nodejs verion 10 is a bridge too far for rpi-gpio and dependencies (epoll). So it goes - I'm sure I can work around this and in the meantime will probably downgrade nodejs to v8 temporarily, which is kinda ironic since I wanted newer versions of node.... :-[

2) I found the security warnings on the node modules by running "npm audit" in gateway folder:
                       === npm audit security report ===                       
                                                                               
# Run  npm install socket.io@2.1.1  to resolve 11 vulnerabilities
SEMVER WARNING: Recommended action is a potentially breaking change
.... and goes on to list them.

These vulnerabilities seem to be relevant only if you to have your gateway exposed to the internet (which I don't), so with the little I know, I'm ok with it.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Yup I saw those now, thanks.
I updated socket.io and request,
You might want to try it again, should be 0 vulnerabilities now.
Also keep an eye on any sockets or request issues. I see none so far but ... sockets went from 1.2 to 2.1 :)

bpr

  • NewMember
  • *
  • Posts: 9
  • Country: us
@Felix,
You did indeed annihilate the node module security reports, but I do get the following two errors upon startup (when I run sudo node gateway.js from gateway folder after first running sudo systemctl stop gateway), though can't see any actual problems in function:

[07-31-18_17:26:33.473] [INFO]  LOADING USER METRICS...
[07-31-18_17:26:33.487] [INFO]  LOADING USER METRICS MODULE [_example.js]
[07-31-18_17:26:33.524] [ERROR] Port is opening
[07-31-18_17:26:34.557] [INFO]  AUTHORIZING CONNECTION FROM ::1:50680
[07-31-18_17:26:34.567] [INFO]  NEW CONNECTION FROM 192.168.1.182
[07-31-18_17:26:57.939] [LOG]   >: [118] MOTION V: 4.02v F:75.74 H:70.00 P:101017.00 A:402.73   [RSSI:-38]
[07-31-18_17:26:57.955] [LOG]   post: /home/pi/gateway/data/db/0118_M.bin[1533083217,1]
[07-31-18_17:26:57.976] [LOG]   post: /home/pi/gateway/data/db/0118_F.bin[1533083217,75.74]
[07-31-18_17:26:57.980] [LOG]   post: /home/pi/gateway/data/db/0118_H.bin[1533083217,70]
[07-31-18_17:26:57.984] [LOG]   post: /home/pi/gateway/data/db/0118_RSSI.bin[1533083217,-38]
[07-31-18_17:26:57.990] [ERROR] (node:1959) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[07-31-18_17:26:57.993] [LOG]   >: [118] MOTION V: 4.02v F:75.74 H:70.00 P:101017.00 A:402.73   [RSSI:-39]
[07-31-18_17:26:58.008] [LOG]   post: /home/pi/gateway/data/db/0118_M.bin[1533083218,1]
[07-31-18_17:26:58.012] [LOG]   post: /home/pi/gateway/data/db/0118_F.bin[1533083218,75.74]
[07-31-18_17:26:58.015] [LOG]   post: /home/pi/gateway/data/db/0118_H.bin[1533083218,70]
[07-31-18_17:26:58.018] [LOG]   post: /home/pi/gateway/data/db/0118_RSSI.bin[1533083218,-39]
[07-31-18_17:26:58.039] [LOG]      [118] DB-Updates:1
[07-31-18_17:26:58.045] [LOG]      [118] DB-Updates:1

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
I did see those after the serialport update but before the nodemailer/request updates.
Looks like the first one is related to serialport, although I don't see issues either.
The second might be related to Buffer() use in logUtil.js, I will look into it.

UPDATE: The Buffer error is because of a deprecated use of Buffer() reported here:
https://nodejs.org/en/docs/guides/buffer-constructor-deprecation/

UPDATE2:
I made a new release (8.11.1) which fixes these 2 errors.
« Last Edit: August 01, 2018, 11:10:09 AM by Felix »

bpr

  • NewMember
  • *
  • Posts: 9
  • Country: us
@Felix,
Thanks! Been running your new updates (Latest commit ee62319 4 hours ago) for the past 45 min with no glitches, errors, or listed vulnerabilities at all. The gateway is a fine piece of work and I'm glad you have been able to update it so well.
Thanks again!