Node-RED adminAuth不生效求助:树莓派3 Jessie下编辑器无登录提示
Let's break down the possible issues and fixes for your scenario (Raspberry Pi 3 Jessie, Node.js v0.18.4, Node-RED adminAuth not working):
1. Critical Node.js Version Incompatibility
Node.js v0.18.4 is extremely outdated (released in 2015) and likely incompatible with the adminAuth features in Node-RED. Back when Jessie was supported, Node-RED required at least Node.js 4.x or higher for proper credential handling. Old Node.js versions lack support for modern crypto libraries used to hash passwords and manage sessions, which could be why your auth config is being ignored entirely.
Fix:
Upgrade Node.js to a compatible LTS version for Jessie. For example, Node.js 8.x was the LTS release that worked well with Jessie:
# Add NodeSource repo for Node.js 8.x curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - # Install Node.js sudo apt-get install -y nodejs
After upgrading, verify the version with node -v and re-run your adminAuth setup steps.
2. Syntax Errors in settings.js
It’s easy to introduce typos when uncommenting the adminAuth block. Even a missing comma or bracket will cause Node-RED to ignore the entire auth configuration.
Fix:
Double-check your adminAuth structure matches this exact format (replace the password hash with your own):
adminAuth: { type: "credentials", users: [{ username: "your-username", password: "$2a$08$your-generated-hash-here", permissions: "*" }] }
- Ensure
usersis an array (wrapped in[]), not just a single object. - Confirm all commas are present between key-value pairs and objects.
- Avoid any trailing commas at the end of the object/array (old Node.js versions are strict about this).
3. Mismatched node-red-admin Version
Globally installing node-red-admin with sudo npm install -g might pull a version that’s incompatible with your old Node-RED instance. The global tool may generate password hashes that your Node-RED version can’t validate.
Fix:
Install node-red-admin locally in your Node-RED user directory instead:
cd ~/.node-red npm install node-red-admin
Generate the hash using the local tool:
./node_modules/.bin/node-red-admin hash-pw
Use this hash in your settings.js instead of the global tool’s output.
4. File Permissions or Wrong Configuration Path
If you’re starting Node-RED with sudo, it runs as the root user, which reads configuration from /root/.node-red/settings.js instead of your pi user’s ~/.node-red/ directory. Also, incorrect permissions on .node-red/ or sessions.json can break session management.
Fixes:
- Run Node-RED as your user: Instead of
sudo node-red, usenode-red(or set up the service to run aspi). - Fix directory permissions:
sudo chown -R pi:pi ~/.node-red touch ~/.node-red/sessions.json sudo chown pi:pi ~/.node-red/sessions.json - If using root: Copy your modified
settings.jsto/root/.node-red/and ensure permissions are correct for root.
5. Browser Cache Caching Old Sessions
Your browser might be holding onto a cached, unauthenticated session that bypasses the login prompt.
Fix:
- Open the Node-RED editor in an incognito/private browsing window.
- Clear your browser’s cache and cookies for the Node-RED URL, then refresh.
Final Steps After Fixes
- Save your
settings.jsfile. - Fully stop and restart Node-RED:
# If using the official service sudo systemctl restart node-red # If running manually node-red-stop && node-red-start - Access the editor again—you should now see the login prompt.
内容的提问来源于stack exchange,提问作者Namah

