Here are some short and sweet instructions for setting up your Raspberry Pi for Node.js dev and creating a base image that can be used over and over again. Many of the steps below are taken from the amazing DaveJ posts and I added a few steps that I like to do as well. You can read his posts for more context on why I’m doing what I’m doing.
This step is optional, but probably a good thing to do so you know you are starting off with a clean SD Card.
2. Flash Raspbian to SD Card using Win32 Disk Imager
Click on Wifi icon in top right. Select your network.
- Click Expand Filesystem
- Change Password
- Change Hostname – to anything you want.
- Enable All Interfaces
- Set Locale
- Set Timezone
- Set Keyboard
Not sure why, but I had to set keyboard on the device itself. The dialog wouldn’t popup over xrdp. I set to US.
- Set Wifi Country
Run to set a file share and password for samba that you will use to connect via Windows.
Map Network Drive to **\rpi1\PiShare
Create a directory called “code” to put your code in.
This moves your npm global node_modules folder to /home/pi/.npm-packages/lib/ and allows you to install packages without using “sudo”
- Hit enter when it asks you for home directory- Type “y” and hit enter when it asks you to update bashrc/zshrc files
Here are the packages I need at the moment. Yours will be different.Remove/add as you see fit.If you run the above and get node-gyp, you can ignore them. ## 12\. Configure Packages The "noble" package doesn't run without "sudo" by default. Here's how to configure to allow you to run without sudo. Instructions from [here](https://github.com/sandeepmistry/noble#running-on-linux). You don't need to do this step if you don't install noble.
Now that you have all the settings the way you want them, you can use Win32 Disk Imager to write it to disk, so you can use this as a base image for future Raspberry Pis.
IMPORTANT: Make sure you use an SD card that is smaller than your target SD card or else you won’t be able to copy this image to it later.