SA515安装node.js和node-red
1.先安装node.js
直接官网下载ARMv7版可执行文件:https://nodejs.org/en/download
当前使用的最新版本:https://nodejs.org/dist/v18.16.0/node-v18.16.0-linux-armv7l.tar.xz
2.导入开发板,这里以/usrdata为例
adb push node-v18.16.0-linux-armv7l.tar.xz /usrdata
tar -vxf node-v18.16.0-linux-armv7l.tar.xz
mv -f node-v18.16.0-linux-armv7l node-v18.16
cd node-v18.16/bin
./node -v
./node: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory
#执行失败,提示找不到libatomic.so.1,从yocto环境导入libatomic.so.1.2.0到/usrdata,创建软链接:
ln -s libatomic.so.1.2.0 libatomic.so.1
#修改库路径:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usrdata
./node -v
v18.16.0
3.安装node-red
#开发板在线安装node-red会比较占资源,极有可能因为RAM问题被系统kill掉.
#建议ubuntu安装好之后导入开发板.
npm install -g node-red
#安装之后压缩node_modules下面的node-red文件夹,生成node-red.tar.gz
adb push node-red.tar.gz /usrdata
cd /usrdata
tar -vxf node-red.tar.gz -C node-v18.16/lib/node_modules
4.运行
修改环境变量HOME
mkdir -p /usrdata/nodejs
export HOME=/usrdata/nodejs #npm和node-red需要用到HOME环境变量
cd /usrdata/node-v18.16/bin
创建node-red的软链接
ln -s ../lib/node_modules/node-red/red.js red
./node red -u /usrdata/nodejs #如果不用-u指定路径,则默认使用HOME路径.
#显示如下即表示启动成功.
4 May 06:34:29 - [info]
Welcome to Node-RED
===================
4 May 06:34:29 - [info] Node-RED version: v3.0.2
4 May 06:34:29 - [info] Node.js version: v18.16.0
4 May 06:34:29 - [info] Linux 4.14.206-perf arm LE
4 May 06:34:34 - [info] Loading palette nodes
4 May 06:34:41 - [info] Settings file : /usrdata/nodejs/settings.js
4 May 06:34:41 - [info] Context store : 'default' [module=memory]
4 May 06:34:41 - [info] User directory : /usrdata/nodejs
4 May 06:34:41 - [warn] Projects disabled : editorTheme.projects.enabled=false
4 May 06:34:41 - [info] Flows file : /usrdata/nodejs/flows.json
4 May 06:34:41 - [info] Creating new flow file
4 May 06:34:41 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
4 May 06:34:41 - [warn] Encrypted credentials not found
4 May 06:34:41 - [info] Server now running at http://127.0.0.1:1880/
4 May 06:34:41 - [info] Starting flows
4 May 06:34:41 - [info] Started flows
5.web端启动
6.安装节点
#以安装gRPC和serialport为例
#Node-red web端打开节点管理->安装.
#搜索gRPC找到node-red-contrib-grpc.
#搜索serialport找到node-red-node-serialport.
#点安装即可,一般可能报错,提示路径问题.
#配置npm环境.
mkdir -p /usrdata/nodejs/node_global
mkdir -p /usrdata/nodejs/node_cache
#设置默认安装路径
./node npm config set prefix "/usrdata/nodejs/node_global"
./node npm config set cache "/usrdata/nodejs/node_cache"
#配置过来镜像源
npm config set registry https://registry.npm.taobao.org/
标签:node,usrdata,06,May,34,Linux,js,red
From: https://www.cnblogs.com/edenpei/p/17371407.html