树莓派Respberry Pi安装node和npm
You can build many apps using node.js and npm on your raspberry pi and it's very easy to interact with GPIO or other components connected to your raspberry pi. So if you are like me and like to do it on node.js here a few simple steps to install node and npm.
Add TipAsk QuestionCommentDownload
Tokyo, Tokyo Prefecture: See our Editor's Choice for Home Security."...the best home security system." - The Wirecutter
![]()
Sponsored by SimpliSafe
Step 1: Detect What Version of Node.js You Need
The processor on Raspberry Pi is ARM, but depends on the model there can be ARMv6, ARMv7 or ARMv8. This 3 versions of ARM is supported by Node.js.
So first of all type this in your terminal on raspberry pi to detect the version that you need:
uname -m
If the response starts with armv6 than that's the version that you will need. For example for raspberry pi zero W you will need ARMv6
Add TipAsk QuestionCommentDownload
Step 2: Download Node.JS Linux Binaries for ARM
Go to node.js download page and check right click on the version of ARM that you need and choose Copy Link address.
After that in the terminal using wget download the tar.gz file for that version. Just type wget, paste the link copied before and make sure the extension is .tar.gz. If it's something else change it to this and it should be ok. For example I will need ARMv6 and I will type this in my terminal:
wget https://nodejs.org/dist/v8.9.0/node-v8.9.0-linux-armv6l.tar.gz
Add TipAsk QuestionCommentDownload
Step 3: Extract the Archive
Using tar that is already installed with the system on your raspberry pi just type this (make sure you change the filename with the file that you have)
tar -xzf node-v8.9.0-linux-armv6l.tar.gz
Add TipAsk QuestionCommentDownload
Step 4: Copy Node to /usr/local
cd node-v6.11.1-linux-armv6l/
sudo cp -R * /usr/local/
Add TipAsk QuestionCommentDownload
Step 5: Check If Everything Is Installed Ok
Check if node and npm are installed correctly. This lines should print the version of node and npm installed.
node -v
npm -v
Now you have node.js installed on your Raspberry Pi and working so you can build something using node
创客必备:https://shop368495242.taobao.com/?spm=a21ar.c-ca-1.smart.5.7HX5xa
本文介绍在树莓派上安装Node.js和npm的详细步骤,包括检测所需Node.js版本、下载ARM版本的Node.js、解压归档文件、复制到系统目录以及检查安装情况,帮助读者轻松在树莓派上搭建Node.js环境。


299

被折叠的 条评论
为什么被折叠?



