ENODEV means npm or a native Node.js module cannot access a required hardware device or system resource. This typically occurs with USB serial ports, Bluetooth adapters, or when devices are disconnected during installation.
The ENODEV error (errno 19) is a system-level error indicating that the operating system cannot find or access a device that a Node.js package is trying to use. This commonly occurs with native modules that require hardware access, such as serial port libraries (node-serialport), Bluetooth modules (noble), or USB HID devices. Unlike most npm errors, ENODEV isn't directly an npm problem—it's your system telling Node.js that a device it's looking for doesn't exist, isn't connected, or isn't accessible. The error can happen during installation if npm tries to build native extensions that require hardware, or at runtime when a package attempts to access a disconnected device.
Before troubleshooting npm, confirm the hardware device is physically connected and your operating system can see it.
On Linux:
lsusb # List all connected USB devices
ls -la /dev/ttyUSB* # For serial ports
ls -la /dev/ttyACM* # For Arduino-style devicesOn macOS:
ls -la /dev/tty.* /dev/cu.* # Serial portsOn Windows:
Mode COM3: # Check if COM port exists (replace COM3 with your port)If your device doesn't appear, reconnect it or check if you need to install drivers.
On Linux and macOS, you may need special permissions to access USB and serial devices. Check if you're in the correct user group.
On Linux (add your user to dialout group for serial ports):
# Check current groups
groups
# Add user to dialout group
sudo usermod -a -G dialout $USER
# For USB devices, you may need plugdev group
sudo usermod -a -G plugdev $USER
# Apply new group membership (logout and login, or use:)
newgrp dialoutAfter changing groups, logout and log back in for changes to take effect.
Native npm modules need proper drivers to access devices.
For Serial/USB devices:
- Check manufacturer websites for the latest drivers for your OS
- Arduino, FTDI, Prolific chips each have specific drivers
- On macOS, you may need to install additional drivers (check System Preferences > Security & Privacy)
On Linux, install required development libraries:
# For building native modules that access USB/serial
sudo apt-get install build-essential python3 libusb-1.0-0 libusb-1.0-0-dev
# For serial port support
sudo apt-get install libudev-devFor Bluetooth modules specifically:
# Linux - Install Bluetooth development libraries
sudo apt-get install libbluetooth-devSometimes native modules need to be recompiled for your system. This is especially important after changing device drivers or updating Node.js.
# Clean rebuild of all native modules
npm rebuild
# Or rebuild a specific package
npm rebuild serialport
# Clear cache and reinstall if rebuild doesn't work
npm cache clean --force
rm -rf node_modules package-lock.json
npm installIf the rebuild fails with errors about missing development tools, install build dependencies (see Step 3).
If running in Docker, VirtualBox, or another container, the device must be explicitly passed through.
Docker - Pass through USB device:
# Find the device
lsusb
# Bus 001 Device 003: ID 1234:5678
# Run container with device access
docker run --device=/dev/bus/usb/001/003 -it your-image
# Or for serial ports
docker run --device=/dev/ttyUSB0 -it your-image
# In docker-compose.yml:
services:
app:
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
- /dev/bus/usb:/dev/bus/usbVirtualBox - Enable USB support:
1. Shut down the virtual machine
2. Settings > USB
3. Enable "Enable USB Controller" and "Enable USB 2.0"
4. Add specific devices or create a USB filter
5. Restart the VM
ENODEV is particularly common with packages like node-serialport, noble (Bluetooth), node-hid, and usb. On Linux, you can create persistent udev rules for USB devices to ensure consistent naming and permissions across reboots: create a file /etc/udev/rules.d/99-usb-devices.rules with content like SUBSYSTEMS=="usb", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", MODE="0666" (replace vendor/product IDs), then run sudo udevadm control --reload. For Bluetooth on Linux, ensure the bluetooth service is running (sudo systemctl status bluetooth). On macOS Monterey and later, Bluetooth HID access requires additional code signing and entitlements.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EWORKSPACEMISSING npm ERR! Workspace does not exist: packages/missing
How to fix "npm ERR! code EWORKSPACEMISSING - Workspace does not exist" error
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error