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

> [email protected] 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

> [email protected] 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/
发布了1112 篇原创文章 · 获赞 1312 · 访问量 407万+

猜你喜欢

转载自blog.csdn.net/liumiaocn/article/details/104667193
今日推荐