Node-RED使用指南:3:使用源码方式安装

在这里插入图片描述
在需要使用最新代码或者需要进行定制化开发时,则一般需要从源码方式进行安装,在本文中对这种使用方式进行介绍。

整体步骤

和大多数基于npm打包的应用一样,按步骤使用如下命令即可完成Node-RED的安装与服务启动。

  • 步骤1: 下载源码

执行命令: git clone https://github.com/node-red/node-red.git

  • 步骤2: 安装依赖

执行命令: cd node-red; npm install

  • 步骤3: 执行构建

执行命令: npm run build

  • 步骤4: 运行Node-RED

执行命令: npm start

安装与说明

  • 下载源码
liumiaocn:~ liumiao$ git clone https://github.com/node-red/node-red.git
Cloning into 'node-red'...
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 48916 (delta 0), reused 4 (delta 0), pack-reused 48905
Receiving objects: 100% (48916/48916), 19.04 MiB | 262.00 KiB/s, done.
Resolving deltas: 100% (33405/33405), done.
liumiaocn:~ liumiao$
  • 安装依赖
liumiaocn:~ liumiao$ cd node-red; npm install
...省略
added 1219 packages from 1528 contributors in 109.95s
...省略
liumiaocn:node-red liumiao$ ls
API.md			CONTRIBUTING.md		README.md		node_modules		packages
CHANGELOG.md		Gruntfile.js		SECURITY.md		package-lock.json	scripts
CODE_OF_CONDUCT.md	LICENSE			jsdoc.json		package.json		test
liumiaocn:node-red liumiao$ 
  • 执行构建
liumiaocn:node-red liumiao$ npm run build

> node-red@1.0.4 build /Users/liumiao/node-red
> grunt build

Running "clean:build" (clean) task
>> 0 paths cleaned.

Running "jsonlint:messages" (jsonlint) task
>> 30 files lint free.

Running "jsonlint:keymaps" (jsonlint) task
>> 1 file lint free.

Running "concat:build" (concat) task

Running "concat:vendor" (concat) task

Running "copy:build" (copy) task
Created 10 directories, copied 83 files

Running "uglify:build" (uglify) task
>> 4 files created 1.68 MB → 654.32 kB

Running "sass:build" (sass) task

Running "attachCopyright:js" (attachCopyright) task
Attached copyright to packages/node_modules/@node-red/editor-client/public/red/red.min.js
Attached copyright to packages/node_modules/@node-red/editor-client/public/red/main.min.js

Running "attachCopyright:css" (attachCopyright) task
Attached copyright to packages/node_modules/@node-red/editor-client/public/red/style.min.css

Done.
liumiaocn:node-red liumiao$
  • 运行Node-RED
liumiaocn:node-red liumiao$ npm start

> node-red@1.0.4 start /Users/liumiao/node-red
> node packages/node_modules/node-red/red.js

5 Mar 06:30:16 - [info] 

Welcome to Node-RED
===================

5 Mar 06:30:16 - [info] Node-RED version: v1.0.4
5 Mar 06:30:16 - [info] Node.js  version: v10.15.3
5 Mar 06:30:16 - [info] Darwin 19.2.0 x64 LE
5 Mar 06:30:16 - [info] Loading palette nodes
5 Mar 06:30:16 - [info] Settings file  : /Users/liumiao/.node-red/settings.js
5 Mar 06:30:16 - [info] Context store  : 'default' [module=memory]
5 Mar 06:30:16 - [info] User directory : /Users/liumiao/.node-red
5 Mar 06:30:16 - [warn] Projects disabled : editorTheme.projects.enabled=false
5 Mar 06:30:16 - [info] Flows file     : /Users/liumiao/.node-red/flows_liumiaocn.json
5 Mar 06:30:16 - [info] Creating new flow file
5 Mar 06:30:16 - [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.
---------------------------------------------------------------------

5 Mar 06:30:16 - [info] Starting flows
5 Mar 06:30:16 - [info] Started flows
5 Mar 06:30:16 - [info] Server now running at http://127.0.0.1:1880/
  • 结果确认
    在这里插入图片描述

注:也可以指定端口和其他设定,执行示例如下所示:

liumiaocn:node-red liumiao$ node packages/node_modules/node-red/red.js -p 8080
5 Mar 06:32:04 - [info] 

Welcome to Node-RED
===================

5 Mar 06:32:04 - [info] Node-RED version: v1.0.4
5 Mar 06:32:04 - [info] Node.js  version: v10.15.3
5 Mar 06:32:04 - [info] Darwin 19.2.0 x64 LE
5 Mar 06:32:05 - [info] Loading palette nodes
5 Mar 06:32:05 - [info] Settings file  : /Users/liumiao/.node-red/settings.js
5 Mar 06:32:05 - [info] Context store  : 'default' [module=memory]
5 Mar 06:32:05 - [info] User directory : /Users/liumiao/.node-red
5 Mar 06:32:05 - [warn] Projects disabled : editorTheme.projects.enabled=false
...省略
5 Mar 06:32:05 - [info] Started flows
5 Mar 06:32:05 - [info] Server now running at http://127.0.0.1:8080/
淼叔 CSDN认证博客专家 神经网络 TensorFlow NLP
资深架构师,PMP、OCP、CSM、HPE University讲师,EXIN DevOps Professional与DevOps Master认证讲师,曾担任HPE GD China DevOps & Agile Leader,帮助企业级客户提供DevOps咨询培训以及实施指导。熟悉通信和金融领域,有超过十年金融外汇行业的架构设计、开发、维护经验,在十几年的IT从业生涯中拥有了软件开发设计领域接近全生命周期的经验和知识积累,著有企业级DevOps技术与工具实战。
已标记关键词 清除标记
相关推荐
<p> <span style="color:#313d54;font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;font-size:16px;background-color:#ffffff;">Node-RED是工业网物联网的重要组成部分,我最开始接触Node-RED,也算是一个偶然的机会吧,上班后领导安排我的第一个任务就是调研一下Node-RED,我之后上网查了一下,那个时候网上相对于Node-RED的资料也比较少,只知道它是IBM公司的一个开源项目。直到最近,发现许多大公司的产品都支持Node-RED,比如西门子公司的IoT2000,研华公司的WISE PaaS 网关,美国OPTO 22等设备中都安装Node-RED,表明它在工业物联网和控制中已经广泛应用了。</span> </p> <p> <img src="https://img-bss.csdnimg.cn/202010200935441926.png" alt="" width="1316" height="524" /> </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> 那么工业物联网为什么要用它?它又处于工业物联网那个层次?它具有哪些特性?它帮助物联网解决了什么问题?为什么说它是柔性动态可重构的解决方案呢? </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;">   </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;">   </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> 本门课程,老师将带领你从Node-RED的发展,工业物联网定位开始讲解,并带领着大家进行手把手安装Node-RED,实际操作演练Node-RED,并搭建一个物联网小平台,给大家带来更好的学习效果。 </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> <img src="https://img-bss.csdnimg.cn/202010200936289051.png" alt="" width="1841" height="948" /> </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> <img src="https://img-bss.csdnimg.cn/202010200936561564.png" alt="" width="1920" height="977" /> </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;">   </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;">   </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> 为了能够让小伙伴们快速了解本门课程的结构,本门课程从以下几个方面展开: </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> Node-RED入门 </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> Node-RED安装与配置 </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> Node-RED教学实战 </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> Node-RED的优势与不足 </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> Node-RED能为我们带来什么 </p> <p style="font-family:&#39;Helvetica Neue&#39;, Helvetica, &#39;Hiragino Sans GB&#39;, Arial, sans-serif;color:#313d54;font-size:16px;background-color:#ffffff;"> Node-RED总结与展望 </p>
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页