使用HTTP API安装红色节点时,返回代码MODULE_NOT_FOUND

问题描述

当前,我正在尝试使用HTTP curl / nodes通过以下curl命令在NodeRED中安装节点:

curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -i http://localhost:1880/nodes -d "{\"module\": \"C:\\test\\testRemoteNodeWindow\"}"

但是我得到一个400错误的请求响应,这是一个

{“代码”:“ MODULE_NOT_FOUND”,“消息”:“找不到模块'C:\ test \ testRemoteNodeWindow'”}

但是我注意到,该节点已作为依赖项添加到node_red_config / package.json

{
  "name": "node-red-project","description": "A Node-RED Project","version": "0.0.1","private": true,"dependencies": {
    "testRemoteNodeWindow": "file:testRemoteNodeWindow"
 }
}

并且符号链接是在node_red_config / node_modules中创建的,仅在Windows中才出现问题,奇怪的是我在Linux机器中使用相同的node / node-red / npm版本,并且该节点是使用HTTP创建的POST / node没有任何问题。有谁知道这可能是配置问题还是类似的问题? 问候。

解决方法

MODULE_NOT_FOUND错误意味着,虽然它成功运行了模块的npm install,但是运行时却未能找到具有该名称的有效Node-RED模块。

这通常意味着您的模块在其node-red文件中没有package.json节,如here所述。否则,运行时将无法将该模块识别为有效的Node-RED模块。

,

我发现了这个问题,例如与Windows路径有关的问题:

public static void main(String[] args) {
    int[][] grid = new int[9][9];
    int value = 10;
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            grid[i][j] = ++value;
        }
    }

    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            System.out.print(((j == 0) ? "" : ",") + grid[i][j]);
        }
        System.out.println();
    }
}

该节点已安装,并且正在获取HTTP 200响应,但是如果使用:

curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:1880/nodes -d "{\"module\": \"C:/test/testRemoteNodeWindow\"}"

我得到了MODULE_NOT_FOUND代码。