Hi,
On this system:
rock@rockpis:~$ uname -a
Linux rockpis 4.4.143-55-rockchip-g6b7accbc999b #1 SMP PREEMPT Wed Jul 29 02:54:35 UTC 2020 aarch64 GNU/Linux
rock@rockpis:~$ node -v
v12.19.0
rock@rockpis:~$ npm -v
6.14.8
rock@rockpis:~$ mraa-gpio version
Version v2.0.0-57-gf374a26 on Radxa ROCK Pi S
I try example from /usr/share/mraa/examples/javascript/GPIO_DigitalWrite.js
and receive this:
rock@rockpis:~/example$ node GPIO_DigitalWrite.js
internal/modules/cjs/loader.js:834
throw err;
^
Error: Cannot find module ‘mraa’
Require stack:
- /home/rock/example/GPIO_DigitalWrite.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/home/rock/example/GPIO_DigitalWrite.js:10:14)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
code: ‘MODULE_NOT_FOUND’,
requireStack: [ ‘/home/rock/example/GPIO_DigitalWrite.js’ ]
}
Then I try to install mraa, but finished with error:
rock@rockpis:~/example$ sudo npm install mraa
[sudo] password for rock:
mraa@1.9.0 install /home/rock/example/node_modules/mraa
node-gyp rebuild
gyp WARN EACCES current user (“rock”) does not have permission to access the dev dir “/root/.cache/node-gyp/15.0.1”
gyp WARN EACCES attempting to reinstall using temporary dev dir “/home/rock/example/node_modules/mraa/.node-gyp”
make: Entering directory ‘/home/rock/example/node_modules/mraa/build’
CC(target) Release/obj.target/mraa/src/x86/intel_joule_expansion.o
CC(target) Release/obj.target/mraa/src/x86/up2.o
– shortened –
CC(target) Release/obj.target/mraa/src/gpio/gpio.o
CC(target) Release/obj.target/mraa/src/mraa.o
…/src/mraa.c: In function ‘imraa_init’:
…/src/mraa.c:157:2: error: #error mraa_ARCH NOTHING
#error mraa_ARCH NOTHING
^~~~~
make: *** [mraa.target.mk:156: Release/obj.target/mraa/src/mraa.o] Error 1
make: Leaving directory ‘/home/rock/example/node_modules/mraa/build’
gyp ERR! build error
gyp ERR! stack Error:make
failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (node:events:327:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
gyp ERR! System Linux 4.4.143-55-rockchip-g6b7accbc999b
gyp ERR! command “/home/rock/example/node_modules/node/bin/node” “/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
gyp ERR! cwd /home/rock/example/node_modules/mraa
gyp ERR! node -v v15.0.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open ‘/home/rock/example/package.json’
npm WARN example No description
npm WARN example No repository field.
npm WARN example No README data
npm WARN example No license field.npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mraa@1.9.0 install:node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mraa@1.9.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
How to install mraa for use with javascript?