schroeder-robert / vantelligence_connector

A MQTT connector for devices in your camper!
MIT License
7 stars 5 forks source link

SyntaxError #2

Closed wolfgangmauer closed 10 months ago

wolfgangmauer commented 1 year ago

file:///home/wolfgang/vantelligence_connector/device/BME280.js:47 if (values?.temperature_C) { ^

SyntaxError: Unexpected token '.' at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18) at async link (internal/modules/esm/module_job.js:42:21)

I don't know js at all, but with C# it's a check for "null". If I remove the question mark, everything works.... Do I have too old programs?

raspberry pi 4: npm -> 7.5.2 raspberry pi 4: nodejs -> v12.22.12

schroeder-robert commented 11 months ago

Hey Wolfgang!

Is that problem still present?

If so, please make sure you use a recent node version (>= 18) and the newest code.

wolfgangmauer commented 10 months ago

Yes :-( -> Pi 32-bit Lite OS

pi@raspberry:~/vantelligence_connector $ node ./ node:internal/errors:496 ErrorCaptureStackTrace(err); ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'chalk' imported from /home/pi/vantelligence_connector/app.js at new NodeError (node:internal/errors:405:5) at packageResolve (node:internal/modules/esm/resolve:782:9) at moduleResolve (node:internal/modules/esm/resolve:831:20) at defaultResolve (node:internal/modules/esm/resolve:1036:11) at DefaultModuleLoader.resolve (node:internal/modules/esm/loader:251:12) at DefaultModuleLoader.getModuleJob (node:internal/modules/esm/loader:140:32) at ModuleWrap. (node:internal/modules/esm/module_job:76:33) at link (node:internal/modules/esm/module_job:75:36) { code: 'ERR_MODULE_NOT_FOUND' }

Node.js v20.5.1 pi@raspberry:~/vantelligence_connector $ npm install chalk npm ERR! code 1 npm ERR! path /home/pi/vantelligence_connector/node_modules/rpio npm ERR! command failed npm ERR! command sh -c node-gyp rebuild npm ERR! make: Entering directory '/home/pi/vantelligence_connector/node_modules/rpio/build' npm ERR! CXX(target) Release/obj.target/rpio/src/rpio.o npm ERR! make: Leaving directory '/home/pi/vantelligence_connector/node_modules/rpio/build' npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@9.4.0 npm ERR! gyp info using node@20.5.1 | linux | arm npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3" npm ERR! gyp info spawn /usr/bin/python3 npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py', npm ERR! gyp info spawn args 'binding.gyp', npm ERR! gyp info spawn args '-f', npm ERR! gyp info spawn args 'make', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/home/pi/vantelligence_connector/node_modules/rpio/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/home/pi/.cache/node-gyp/20.5.1/include/node/common.gypi', npm ERR! gyp info spawn args '-Dlibrary=shared_library', npm ERR! gyp info spawn args '-Dvisibility=default', npm ERR! gyp info spawn args '-Dnode_root_dir=/home/pi/.cache/node-gyp/20.5.1', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/home/pi/.cache/node-gyp/20.5.1/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/pi/vantelligence_connector/node_modules/rpio', npm ERR! gyp info spawn args '-Dnode_engine=v8', npm ERR! gyp info spawn args '--depth=.', npm ERR! gyp info spawn args '--no-parallel', npm ERR! gyp info spawn args '--generator-output', npm ERR! gyp info spawn args 'build', npm ERR! gyp info spawn args '-Goutput_dir=.' npm ERR! gyp info spawn args ] npm ERR! gyp info spawn make npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] npm ERR! In file included from ../../nan/nan.h:178, npm ERR! from ../src/rpio.cc:17: npm ERR! ../../nan/nan_callbacks.h:55:23: error: ‘AccessorSignature’ is not a member of ‘v8’ npm ERR! 55 | typedef v8::Local Sig; npm ERR! | ^~~~~ npm ERR! ../../nan/nan_callbacks.h:55:40: error: template argument 1 is invalid npm ERR! 55 | typedef v8::Local Sig; npm ERR! | ^ npm ERR! In file included from ../src/rpio.cc:17: npm ERR! ../../nan/nan.h: In function ‘bool Nan::IdleNotification(int)’: npm ERR! ../../nan/nan.h:685:32: warning: ‘bool v8::Isolate::IdleNotificationDeadline(double)’ is deprecated: Use MemoryPressureNotification() to influence the GC schedule. [-Wdeprecated-declarations] npm ERR! 685 | idle_time_in_ms 0.001); npm ERR! | ^ npm ERR! In file included from /home/pi/.cache/node-gyp/20.5.1/include/node/v8-initialization.h:13, npm ERR! from /home/pi/.cache/node-gyp/20.5.1/include/node/v8.h:34, npm ERR! from /home/pi/.cache/node-gyp/20.5.1/include/node/node.h:73, npm ERR! from ../../nan/nan.h:58, npm ERR! from ../src/rpio.cc:17: npm ERR! /home/pi/.cache/node-gyp/20.5.1/include/node/v8-isolate.h:1293:8: note: declared here npm ERR! 1293 | bool IdleNotificationDeadline(double deadline_in_seconds); npm ERR! | ^~~~~~~~ npm ERR! In file included from ../src/rpio.cc:17: npm ERR! ../../nan/nan.h: In function ‘void Nan::SetAccessor(v8::Local, v8::Local, Nan::GetterCallback, Nan::SetterCallback, v8::Local, v8::AccessControl, v8::PropertyAttribute, Nan::imp::Sig)’: npm ERR! ../../nan/nan.h:2551:16: error: no matching function for call to ‘v8::ObjectTemplate::SetAccessor(v8::Local&, void (&)(v8::Local, const v8::PropertyCallbackInfo&), void (&)(v8::Local, v8::Local, const v8::PropertyCallbackInfo&), v8::Local&, v8::AccessControl&, v8::PropertyAttribute&, Nan::imp::Sig&)’ npm ERR! 2551 | , signature); npm ERR! | ^ npm ERR! In file included from /home/pi/.cache/node-gyp/20.5.1/include/node/v8-function.h:15, npm ERR! from /home/pi/.cache/node-gyp/20.5.1/include/node/v8.h:33, npm ERR! from /home/pi/.cache/node-gyp/20.5.1/include/node/node.h:73, npm ERR! from ../../nan/nan.h:58, npm ERR! from ../src/rpio.cc:17: npm ERR! /home/pi/.cache/node-gyp/20.5.1/include/node/v8-template.h:809:8: note: candidate: ‘void v8::ObjectTemplate::SetAccessor(v8::Local, v8::AccessorGetterCallback, v8::AccessorSetterCallback, v8::Local, v8::AccessControl, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)’ npm ERR! 809 | void SetAccessor( npm ERR! | ^~~ npm ERR! /home/pi/.cache/node-gyp/20.5.1/include/node/v8-template.h:814:22: note: no known conversion for argument 7 from ‘Nan::imp::Sig’ {aka ‘int’} to ‘v8::SideEffectType’ npm ERR! 814 | SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, npm ERR! | ~~~^~~~~~~~~~~~ npm ERR! /home/pi/.cache/node-gyp/20.5.1/include/node/v8-template.h:816:8: note: candidate: ‘void v8::ObjectTemplate::SetAccessor(v8::Local, v8::AccessorNameGetterCallback, v8::AccessorNameSetterCallback, v8::Local, v8::AccessControl, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)’ npm ERR! 816 | void SetAccessor( npm ERR! | ^~~ npm ERR! /home/pi/.cache/node-gyp/20.5.1/include/node/v8-template.h:821:22: note: no known conversion for argument 7 from ‘Nan::imp::Sig’ {aka ‘int’} to ‘v8::SideEffectType’ npm ERR! 821 | SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, npm ERR! | ~~~^~~~~~~~~~~~ npm ERR! In file included from ../../nan/nan.h:58, npm ERR! from ../src/rpio.cc:17: npm ERR! ../src/rpio.cc: At global scope: npm ERR! /home/pi/.cache/node-gyp/20.5.1/include/node/node.h:1166:7: warning: cast between incompatible function types from ‘void ()(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void ()(v8::Local)’} to ‘node::addon_register_func’ {aka ‘void ()(v8::Local, v8::Local, void*)’} [-Wcast-function-type] npm ERR! 1166 | (node::addon_register_func) (regfunc), \ npm ERR! | ^~~~~~~~~ npm ERR! /home/pi/.cache/node-gyp/20.5.1/include/node/node.h:1200:3: note: in expansion of macro ‘NODE_MODULE_X’ npm ERR! 1200 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage) npm ERR! | ^~~~~ npm ERR! ../src/rpio.cc:600:1: note: in expansion of macro ‘NODE_MODULE’ npm ERR! 600 | NODE_MODULE(rpio, setup) npm ERR! | ^~~ npm ERR! make: *** [rpio.target.mk:116: Release/obj.target/rpio/src/rpio.o] Error 1 npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error: make failed with exit code: 2 npm ERR! gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:514:28) npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12) npm ERR! gyp ERR! System Linux 6.1.21-v8+ npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" npm ERR! gyp ERR! cwd /home/pi/vantelligence_connector/node_modules/rpio npm ERR! gyp ERR! node -v v20.5.1 npm ERR! gyp ERR! node-gyp -v v9.4.0 npm ERR! gyp ERR! not ok

schroeder-robert commented 10 months ago

Hey Wolfgang! Wenn du dir einen neuen Stand ziehts (git pull), mach danach am besten immer ein "npm install" hinterher. Denn es kommen immer wieder mal neue Pakete/Abhängigkeiten hinzu, ohne die das Ganze möglicherweise nicht läuft.

wolfgangmauer commented 10 months ago

Mach ich genau so, mit 64Bit und 32Bit(RPi OS Lite) ausprobiert, ohne Erfolg....

wolfgangmauer commented 10 months ago

Es scheint wohl bei dem OS-Lite was zu fehlen, mit der "Full" geht der "npm install" ABER ich habe wohl noch Probleme mit den Abhängigkeiten...

pi@raspberrypi:~/vantelligence_connector $ node ./app.js ✨ Device class found: ADS1115.js node:internal/modules/cjs/loader:1319 return process.dlopen(module, path.toNamespacedPath(filename)); ^

Error: libnode.so.72: cannot open shared object file: No such file or directory at Module._extensions..node (node:internal/modules/cjs/loader:1319:18) at Module.load (node:internal/modules/cjs/loader:1091:32) at Module._load (node:internal/modules/cjs/loader:938:12) at Module.require (node:internal/modules/cjs/loader:1115:19) at require (node:internal/modules/helpers:130:18) at bindings (/home/pi/vantelligence_connector/node_modules/bindings/bindings.js:112:48) at Object. (/home/pi/vantelligence_connector/node_modules/i2c-bus/i2c-bus.js:4:32) at Module._compile (node:internal/modules/cjs/loader:1233:14) at Module._extensions..js (node:internal/modules/cjs/loader:1287:10) at Module.load (node:internal/modules/cjs/loader:1091:32) { code: 'ERR_DLOPEN_FAILED' }

Node.js v20.5.1 pi@raspberrypi:~/vantelligence_connector $

schroeder-robert commented 10 months ago

Kannst du folgendes versuchen?

wolfgangmauer commented 10 months ago

Welche Distri hast du denn installiert?

schroeder-robert commented 10 months ago

Das Pi OS 64-Bit Full

wolfgangmauer commented 10 months ago

Bekomme wieder den Übersetzungsfehler mit der "Full" :-(

wolfgangmauer commented 10 months ago

Es liegt offensichtlich an der Node-Version. Mit

sudo su curl` -fsSL https://deb.nodesource.com/setup_lts.x | bash - && apt-get install -y nodejs exit

funktioniert alles ;-)

schroeder-robert commented 10 months ago

Ich mache noch ein Installationsscript und nehme das da mit rein.