I’m trying to control a DHT-11 sensor though a raspberry pi, however, I can’t even install the node-dht-sensor library. Errors:
sudo npm install node-dht-sensor
npm ERR! code 1
npm ERR! path /home/user1/Desktop/plants 2_1/plants2/node_modules/node-dht-sensor
npm ERR! command failed
npm ERR! command sh -c node-gyp build
npm ERR! make: Entering directory '/home/user1/Desktop/plants 2_1/plants2/node_modules/node-dht-sensor/build'
npm ERR! CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
npm ERR! rm -f Release/obj.target/../node-addon-api/src/nothing.a Release/obj.target/../node-addon-api/src/nothing.a.ar-file-list; mkdir -p `dirname Release/obj.target/../node-addon-api/src/nothing.a`
npm ERR! ar crs Release/obj.target/../node-addon-api/src/nothing.a @Release/obj.target/../node-addon-api/src/nothing.a.ar-file-list
npm ERR! COPY Release/nothing.a
npm ERR! CC(target) Release/obj.target/node_dht_sensor/src/bcm2835/bcm2835.o
npm ERR! make: Leaving directory '/home/user1/Desktop/plants 2_1/plants2/node_modules/node-dht-sensor/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | arm64
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! ../src/bcm2835/bcm2835.c: In function ‘bcm2835_init’:
npm ERR! ../src/bcm2835/bcm2835.c:1786:44: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
npm ERR! 1786 | bcm2835_peripherals_base = (uint32_t *)base_address;
npm ERR! | ^
npm ERR! ../src/bcm2835/bcm2835.c:1818:84: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
npm ERR! 1818 | bcm2835_peripherals = mapmem("gpio", bcm2835_peripherals_size, memfd, (off_t)(uint32_t)bcm2835_peripherals_base);
npm ERR! | ^
npm ERR! ../src/bcm2835/bcm2835.c:1851:84: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
npm ERR! 1851 | bcm2835_peripherals = mapmem("gpio", bcm2835_peripherals_size, memfd, (off_t)(uint32_t)bcm2835_peripherals_base);
npm ERR! | ^
npm ERR! cc: warning: 2_1/plants2/node_modules/node-addon-api: linker input file unused because linking not done
npm ERR! cc: error: 2_1/plants2/node_modules/node-addon-api: linker input file not found: No such file or directory
npm ERR! make: *** [node_dht_sensor.target.mk:114: Release/obj.target/node_dht_sensor/src/bcm2835/bcm2835.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.<anonymous> (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Linux 6.6.20+rpt-rpi-v8
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build"
npm ERR! gyp ERR! cwd /home/user1/Desktop/plants 2_1/plants2/node_modules/node-dht-sensor
npm ERR! gyp ERR! node -v v20.12.2
npm ERR! gyp ERR! node-gyp -v v10.1.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-05-02T11_53_18_812Z-debug-0.log
I have also read the node-dht-sensor readme and I found out about a library called node-gyp, but this also resulted in errors.