What does node-hid do?Node-hid allows you to access USB HID devices from Nodejs projects. This as you might imagine is very handy. Joysticks, mice, keyboards, busylights to name a few but basically anything you can stick into your USB port that supports the HID standard.
Below are basic step by step instructions on everything from installing the image on the Pi and installing node to getting node-hid onboard. This is very basic guidance especially the initial installing the OS and node. If you want screenshots and all the rest go to here.
Installing OS on Pi
Step 1. Download Pi Image
This is a great tool recommended by raspberrypi.org.
Prepare PiStep 1. Upgrade Pi:
$ sudo apt-get updateStep 2. Update packages:
$ sudo apt-get dist-upgrade
Installing Nodejs on Pi armv7+ (This will not work for armv6 Pi's)
Check your Pi version using:
$ uname -mStep 1. Updates Debian apt package repository to include the NodeSource packages:
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -Step 2. Install
$ sudo apt install -y nodejsStep 3. Check node version
$ node -V
Installing node-HID on a Pi
Step 1. Install tools:
Step 2. Compile:
- Compilation tools: $ sudo apt install build-essential git
- gcc-4.8+: $ sudo apt install gcc-4.8 g++-4.8 && export CXX=g++-4.8 (note: not sure how applicable this is)
- libusb-1.0-0 w/headers: $ sudo apt install libusb-1.0-0 libusb-1.0-0-dev (note: possibly already installed)
- libudev-dev: $ sudo apt install libudev-dev
$ npm install node-hid --build-from-sourceStep 3. Move on to building/installing application