Setup Guide: Raspberry Pi | Install Node.js via Node Version Manager (NVM)
rourke edited this page Jan 15, 2018
·
6 revisions
# Install Node Version Manager (NVM)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
# Rerun Profile script to start NVM
source ~/.bashrc # Rerun profile after installing nvm
Installing an ARM-version of Node has become very easy:
# Install Node.js using Node Version Manager
nvm install 8 # Installs Node v8, (nvm install stable) installs Latest version of node
nvm use 8 # Sets Node to use v8
npm install npm@latest -g
To make sure it ran correctly, run npm -v
, nvm --version
, & node -v
. It should return the current versions.
# Output Node Related Version Info
echo "[NPM] ============"; which npm; npm -v;
echo "[NVM] ============"; nvm --version; nvm ls
echo "[NODE] ============"; which node; node -v
### Install Node.JS Serial Port application first (OPTIONAL)
npm install serialport
# Install Latest Release Version of CNCjs
npm install -g cncjs@latest --unsafe-perm
# --- OR ---
# Install Specific Version of CNCjs
#npm install -g cncjs@v1.9.0-beta.1 --unsafe-perm # Installs Specific Version based on TAG
# Allow access to port 8000 from port 80
sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8000
# Make Iptables Persistent
sudo apt-get install iptables-persistent -y
# How-to: Save & Reload Rules
#sudo netfilter-persistent save
#sudo netfilter-persistent reload
# How-to: Manually Save Rules
#sudo sh -c "iptables-save > /etc/iptables/rules.v4"
#sudo sh -c "ip6tables-save > /etc/iptables/rules.v6"
# Run this if issues to reconfigure iptables-persistent
# sudo dpkg-reconfigure iptables-persistent
Install Production Process Manager [PM2]
# Install Production Process Manager [PM2]
npm install pm2 -g
# Start CNCjs (on port 8000) with PM2
pm2 start $(which cncjs) -- --port 8000
# Setup PM2 Startup Script
pm2 startup debian
#[PM2] You have to run this command as root. Execute the following command:
#sudo su -c "env PATH=$PATH:/home/pi/.nvm/versions/node/v{NODE-VERSION}/bin pm2 startup debian -u pi --hp /home/pi"
sudo su -c "env PATH=$PATH:/home/pi/.nvm/versions/node/v6.5.0/bin pm2 startup debian -u pi --hp /home/pi"
# Set current running apps to startup
pm2 save
# Get list of PM2 processes
pm2 list
# Get Node Location (take note of this)
which node
# Open crontab
crontab -u pi -e
# Paste the following into Cron Tab [ NOTE: which cnc # used to find location of application ]
@reboot env PATH=$PATH:/home/pi/.nvm/versions/node/v8.0.0/bin /home/pi/.nvm/versions/node/v8.0.0/bin/cnc >> $HOME/cncjs.log 2>&1
Join CNCjs Users Group on Facebook to share your experiences with other people.
Site: https://cnc.js.org
- Introduction
- Installation
- Using Pendants
-
Raspberry Pi Setup Guide
- System Setup & Preparation
- Install Node.js & CNCjs
- Install Node.js via Package Manager (Recommended)
- Install Node.js via Node Version Manager (NVM) (Alternative)
- Install Node.js Manually (Alternative)
- Use PM2 to auto-start CNCjs (Optional)
- Use Port 80 (Optional)
- Maintain
- Additional Setup Options:
- CNCjs UI on Pi - Adventures in PiLand
- Pi with Arduino Due
- Electron App
- User Guide
- Tool Change
- Troubleshooting
-
FAQ
- Forgot your password?
- How can I enable WebGL in my browser?
- Raspberry Pi: Error opening serial port "ttyAMA0"
- Webcam Streaming with Raspberry Pi
- Restream RTSP to M-JPEG
- Connect to an Arduino using WiFi
- Install Native Addons with Node.js v4
- Install Serialport on OS X El Capitan
- Kernel panic issue on macOS Sierra for devices using the CH340G, CH34G or CH34X chipset
- Testing without Arduino board
- Development
- API
- Wiki History
- Resources
- About