我使用一个相当标准的节点红色项目结构来开发自定义节点:
- <myproject>
- examples
- example.json
- nodes
- node1.html
- node1.js
- libs
- custom_lib (a custom node lib used by nodes)
....
- package.json我的package.json包括:
...
"node-red": {
"nodes": {
"node1": "nodes/node1.js"
}
},
"files": [
"nodes"
"libs"
],
"scripts": {
"debug": "set DEBUG=express:* & nodemon node_modules/node-red/red.js --userDir ./userdata --flowFile ./examples/example.json"
},
dependencies: {
....
}要在本地安装环境,我正在项目中运行:npm install .。它使用所有依赖项创建node_modules。
但是当我运行npm run debug时,节点红色并没有找到本地模块:
18 Feb 14:32:27 - [info] Waiting for missing types to be registered:
18 Feb 14:32:27 - [info] - node1除非我手动创建一个符号链接:
ln -s <path_to_myproject> ./node_modules/<module_name>是否有正确的方法来安装/构造项目,这样我就不需要添加这个手动步骤了(也就是说,我希望通过运行npm install ...来创建一个Docker容器)
发布于 2022-02-18 21:25:58
如果运行以下命令:
npm install /path/to/your/custom_node在Node-RED UserDir ( .userDir)中,它将为您创建正确的符号链接( .userDir/node_modules目录中的节点名称)。
猜你的结构应该是npm install ..
编辑:
根据注释并记住npm的工作方式,您将需要如下目录结构:
project-root
- userDir
- node
- libs
- lib.js
- nodes
- node1.js
- node1.html
- examples
- example.json
- package.json然后,可以让npm从node目录中正确地创建指向userDir目录的符号链接。
https://stackoverflow.com/questions/71179603
复制相似问题