Splines / raspi-captive-portal

⚡ A Captive Portal & Access Point setup for use with the Raspberry Pi (no Internet access)
https://dominicplein.medium.com/captive-portal-access-point-on-the-raspberry-pi-easy-setup-28a9bf72e998
MIT License
27 stars 7 forks source link

Issue with nodeJS install from the script #10

Open nar001 opened 1 month ago

nar001 commented 1 month ago

Description

I seem to be having nodejs installation issues? I'm using Bookworm so it should be supported, but it keeps being unable to finish the setup script. It happened twice on 2 different raspberry pis, and I'm not quite sure how to fix it.

See screenshots ![Screenshot 2024-07-12 093826](https://github.com/user-attachments/assets/823257a4-1843-4a8d-82f6-d27fa99a7165) ![Screenshot 2024-07-12 093842](https://github.com/user-attachments/assets/fd712f1e-16d4-49f4-90fa-8212f4b8f367) ![Screenshot 2024-07-12 094014](https://github.com/user-attachments/assets/dd5deff4-919d-41da-98da-617ea8f0e36a)

Reproduce

I only set up the pi with Bookworm, and then launched the script, that's it. Nothing else, if it helps.

Expected behavior

It just working, as the script installs everything.

System

My Raspberry Pis were a zero with Bookworm 32 bits and a Raspberry pi 3 with Bookworm 64 bits. I also tried with Bullseye, same issue.

nar001 commented 1 month ago

Okay so I seem to have fixed it? But you need to install NodeJS 18 LTS instead of the latest 20 the script automatically installs. Otherwise, it fails like the screencaps I linked.

Splines commented 1 month ago

Thanks for your report. Please paste your code as code block in Markdown next time instead of a screenshot, thanks ;)

So apparently, the following command fails for you: https://github.com/Splines/raspi-captive-portal/blob/ead22800a844c6bd8f00b1750c7c4f09fd52b6f5/setup.py#L71-L73

I've added it since Node.js does not come with npm bundled as far as I know (see also here).

When the command is failing for you, could you type in npm --version afterwards and see if it gives you back the version or rather an error indicating that npm is not installed? I'm wondering why the basic command sudo apt-get install npm fails. Haven't found out what error code 100 means, but will investigate.

I will probably rewrite the installation of Node.js in the script and use nvm, which is a Node Version manager and has worked reliably for me in the past. As a temporary workaround: You may want to follow the instructions in the nvm Readme in order to install Node.js 20 LTS manually. Afterwards, run the setup script here again and it should then detect automatically (via these lines) that you have Node.js installed and therefore skip the installation. If in doubt, just remove these lines of my scripts if you've installed Node.js manually.

Note that you shouldn't have to go back to an older Node.js version. This may even be a security risk. For right now, Node.js 18 is still maintained though. But it should work with LTS 20 without any problems.

nar001 commented 1 month ago

Oh installing NodeJS 18 really fixed it all, not sure what happened, I had a few issues with having to set the country code in hostapd.conf manually after, but otherwise it was smooth sailing. I can try again in the future just to check these though!

tairea commented 1 month ago

Same issue for me on rpi 3b with new Raspberry Pi OS with desktop 64bit bookworm image. As @Splines suggested I installed nvm with curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash then checked which node version it install with node -v resulting in v20.15.1. I ran the setup script again, and it installed without a hitch.

Thanks @Splines for creating this awesome project. You made the process so much easier after days of trying to manually configure a captive portal unsuccessfully. Looking forward to experimenting with your captive-circle offline game, and seeing what cool use cases we can come up with. I will keep you posted. Cheers mate 👊

Splines commented 1 month ago

Thanks @tairea for the kind words 😊 Yes, please keep me posted of what ideas you come up with for a captive portal ;)

And thanks for confirming that the proposed workaround works. I will include the installation of Node.js via nvm in my script in the (near) future, probably at the beginning of August this year.