TotallyInformation / node-red-contrib-uibuilder

Easily create data-driven web UI's for Node-RED using any (or no) front-end framework.
https://totallyinformation.github.io/node-red-contrib-uibuilder/#/
Apache License 2.0
454 stars 86 forks source link

Node Red not starting after uibuilder install #72

Closed ramonneves closed 5 years ago

ramonneves commented 5 years ago

I have installed uibuilder using the Pallete Manager in Node Red. After that, the initialization crashes at the following point:

1 Oct 15:46:24 - [info] Node-RED version: v1.0.0 1 Oct 15:46:24 - [info] Node.js version: v12.5.0 1 Oct 15:46:24 - [info] Windows_NT 10.0.18362 x64 LE 1 Oct 15:46:25 - [info] Loading palette nodes 1 Oct 15:46:27 - [info] +----------------------------------------------------- 1 Oct 15:46:27 - [info] | uibuilder initialised: 1 Oct 15:46:27 - [info] | root folder: \Users\ramon.node-red\uibuilder 1 Oct 15:46:27 - [info] | version . .: 2.0.4 1 Oct 15:46:27 - [info] | packages . : vue,bootstrap,bootstrap-vue,socket.io 1 Oct 15:46:27 - [info] +----------------------------------------------------- 1 Oct 15:46:27 - [info] Dashboard version 2.16.3 started at /ui 1 Oct 15:46:28 - [red] Uncaught Exception: 1 Oct 15:46:28 - TypeError: cb.apply is not a function at C:\Users\ramon.node-red\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18 at FSReqCallback.oncomplete (fs.js:166:5)

scottpageindysoft commented 5 years ago

Are you in a Docker container by chance? I had a similar issue the other day. I was developing in a container, but I had my volume mount wrong, and I damaged a part of node-red.

If not, I'll have a look and get back to you.

ramonneves commented 5 years ago

No. Is basically a clean node-red install on my PC which I have added uibuilder.

TotallyInformation commented 5 years ago

Node.js version: v12.5.0

This is not yet a version fully supported by Node-RED. Node-RED, in alignment with most things that rely on Node.js, supports the LTS versions. That is currently v8 and v10.

So the workaround would be to use Node.js v10.16.

However, we do need to fix this because v12 is due to go into LTS at the end of this month.

The issue is that the problem seems to reside in a dependency graceful-fs - that is used by LOTS of other packages including Node-RED itself.

With the information you have, I can't tell what is triggering the failure:

C:\src\nr
λ  npm ls graceful-fs
node-red-master@1.0.0-beta.3 C:\src\nr
`-- node-red@1.0.0
  `-- fs-extra@8.1.0
    +-- graceful-fs@4.2.2
    `-- jsonfile@4.0.0
      `-- graceful-fs@4.2.2  deduped

C:\src\nr
λ  cd data
C:\src\nr\data
λ  npm ls graceful-fs
node-red-project@0.0.4 C:\src\nr\data
+-- node-red-contrib-nbrowser@1.1.4
| `-- nightmare@2.10.0
|   `-- electron@1.8.8
|     `-- electron-download@3.3.0
|       +-- fs-extra@0.30.0
|       | +-- graceful-fs@4.2.1
|       | +-- jsonfile@2.4.0
|       | | `-- graceful-fs@4.2.1  deduped
|       | `-- klaw@1.3.1
|       |   `-- graceful-fs@4.2.1  deduped
|       `-- nugget@2.0.1
|         `-- pretty-bytes@1.0.4
|           `-- meow@3.7.0
|             `-- read-pkg-up@1.0.1
|               `-- read-pkg@1.1.0
|                 +-- load-json-file@1.1.0
|                 | `-- graceful-fs@4.2.1  deduped
|                 `-- path-type@1.1.0
|                   `-- graceful-fs@4.2.1  deduped
+-- node-red-contrib-static-markdown@0.0.14 -> C:\src\node-red-contrib-static-markdown
| `-- fs-extra@8.1.0
|   +-- graceful-fs@4.2.0
|   `-- jsonfile@4.0.0
|     `-- graceful-fs@4.2.0  deduped
`-- node-red-contrib-uibuilder@2.0.5-dev -> C:\src\node-red-contrib-uibuilder
  `-- fs-extra@8.1.0
    +-- graceful-fs@4.2.1
    `-- jsonfile@4.0.0
      `-- graceful-fs@4.2.1  deduped
TotallyInformation commented 5 years ago

From the above, you can see that, for some reason, node-red itself has graceful-fs@4.2.2 available but uibuilder only has graceful-fs@4.2.2.

Could you please therefore try manually installing 4.2.2 in your userDir folder?

cd ~/.node-red
npm install graceful-fs@4.2.2

And let us know if that fixes the issue. 4.2.2 is still compatible with fs-extra.

ramonneves commented 5 years ago

Hello, I just did what you've recommended but no success.

npm install graceful-fs@4.2.2

Welcome to Node-RED

6 Oct 11:31:18 - [info] Node-RED version: v1.0.0 6 Oct 11:31:18 - [info] Node.js version: v12.5.0 6 Oct 11:31:18 - [info] Windows_NT 10.0.18362 x64 LE 6 Oct 11:31:19 - [info] Loading palette nodes 6 Oct 11:31:22 - [info] +----------------------------------------------------- 6 Oct 11:31:22 - [info] | uibuilder initialised: 6 Oct 11:31:22 - [info] | root folder: \Users\ramon.node-red\uibuilder 6 Oct 11:31:22 - [info] | version . .: 2.0.4 6 Oct 11:31:22 - [info] | packages . : vue,bootstrap,bootstrap-vue,socket.io 6 Oct 11:31:22 - [info] +----------------------------------------------------- 6 Oct 11:31:22 - [info] Dashboard version 2.16.3 started at /ui 6 Oct 11:31:23 - [red] Uncaught Exception: 6 Oct 11:31:23 - TypeError: cb.apply is not a function at C:\Users\ramon.node-red\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18 at FSReqCallback.oncomplete (fs.js:166:5)

Is there any other test that I could help with?

TotallyInformation commented 5 years ago

Is there any other test that I could help with?

How good is your node.js knowledge?

What I really need is a trace from the point that the error happens. Because that is deep down in a dependency, I can't see what is triggering it. So if you are reasonably comfortable, you could edit the file listed and add a console.trace('TRACE') just before it fails. That should produce a full trace of the entire call chain and I can look at what code is triggering it.

Unfortunately, I don't currently have anywhere with node.js v12 installed. So I'm going to have to try and find somewhere to run that.

In addition, could you please run npm ls graceful-fs from your userDir folder and post back the results - just so that I can be certain there isn't something else strange happening with dependency versions.

Thanks for your patience.

ramonneves commented 5 years ago

How good is your node.js knowledge?

I know js. but Node.js is in my udemy courses queue but didn't have the time yet... I edited the polyfill.js file and added the trace there but the console didn't change much. After that, I've activated the trace logging within node-red and i had the following output:

6 Oct 12:01:27 - [info] Node-RED version: v1.0.0
6 Oct 12:01:27 - [info] Node.js  version: v12.5.0
6 Oct 12:01:27 - [info] Windows_NT 10.0.18362 x64 LE
6 Oct 12:01:28 - [info] Loading palette nodes
6 Oct 12:01:28 - [debug] Module: node-red-contrib-ads 1.1.22
6 Oct 12:01:28 - [debug]         \Users\ramon\.node-red\node_modules\node-red-contrib-ads
6 Oct 12:01:28 - [debug] Module: node-red-contrib-function-npm 0.3.0
6 Oct 12:01:28 - [debug]         \Users\ramon\.node-red\node_modules\node-red-contrib-function-npm
6 Oct 12:01:28 - [debug] Module: node-red-contrib-mic 0.0.1
6 Oct 12:01:28 - [debug]         \Users\ramon\.node-red\node_modules\node-red-contrib-mic
6 Oct 12:01:28 - [debug] Module: node-red-contrib-opcua 0.2.49
6 Oct 12:01:28 - [debug]         \Users\ramon\.node-red\node_modules\node-red-contrib-opcua
6 Oct 12:01:28 - [debug] Module: node-red-contrib-s7 2.0.2
6 Oct 12:01:28 - [debug]         \Users\ramon\.node-red\node_modules\node-red-contrib-s7
6 Oct 12:01:28 - [debug] Module: node-red-contrib-tciot 0.9.7
6 Oct 12:01:28 - [debug]         \Users\ramon\.node-red\node_modules\node-red-contrib-tciot
6 Oct 12:01:28 - [debug] Module: node-red-contrib-uibuilder 2.0.4
6 Oct 12:01:28 - [debug]         \Users\ramon\.node-red\node_modules\node-red-contrib-uibuilder
6 Oct 12:01:28 - [debug] Module: node-red-dashboard 2.16.3
6 Oct 12:01:28 - [debug]         \Users\ramon\.node-red\node_modules\node-red-dashboard
6 Oct 12:01:28 - [debug] Module: node-red-node-email 1.7.1
6 Oct 12:01:28 - [debug]         \Users\ramon\.node-red\node_modules\node-red-node-email
6 Oct 12:01:28 - [debug] Module: node-red-node-rbe 0.2.5
6 Oct 12:01:28 - [debug]         \Users\ramon\.node-red\node_modules\node-red-node-rbe
6 Oct 12:01:28 - [debug] Module: node-red-node-sqlite 0.3.7
6 Oct 12:01:28 - [debug]         \Users\ramon\.node-red\node_modules\node-red-node-sqlite
6 Oct 12:01:28 - [debug] Module: node-red-node-tail 0.0.3
6 Oct 12:01:28 - [debug]         \Users\ramon\.node-red\node_modules\node-red-node-tail
6 Oct 12:01:28 - [debug] Module: node-red-node-rbe 0.2.5 *ignored due to local copy*
6 Oct 12:01:28 - [debug]         C:\Users\ramon\AppData\Roaming\npm\node_modules\node-red\node_modules\node-red-node-rbe
6 Oct 12:01:28 - [debug] Module: node-red-node-tail 0.0.3 *ignored due to local copy*
6 Oct 12:01:28 - [debug]         C:\Users\ramon\AppData\Roaming\npm\node_modules\node-red\node_modules\node-red-node-tail
6 Oct 12:01:30 - [trace] [uibuilder:Module] ----------------- uibuilder - module started -----------------
6 Oct 12:01:30 - [trace] [uibuilder:uiblib.servePackage] Adding user vendor path:  {
  url: '/uibuilder/vendor/vue',
  path: 'C:\\Users\\ramon\\.node-red\\node_modules\\vue'
}
6 Oct 12:01:30 - [trace] [uibuilder:uiblib.servePackage] Adding user vendor path:  {
  url: '/uibuilder/vendor/bootstrap',
  path: 'C:\\Users\\ramon\\.node-red\\node_modules\\bootstrap'
}
6 Oct 12:01:30 - [trace] [uibuilder:uiblib.servePackage] Adding user vendor path:  {
  url: '/uibuilder/vendor/bootstrap-vue',
  path: 'C:\\Users\\ramon\\.node-red\\node_modules\\bootstrap-vue'
}
6 Oct 12:01:30 - [trace] [uibuilder:uiblib.servePackage] Adding user vendor path:  {
  url: '/uibuilder/vendor/socket.io',
  path: 'C:\\Users\\ramon\\.node-red\\node_modules\\socket.io'
}
6 Oct 12:01:30 - [trace] [uibuilder:Module] Socket.IO initialisation - Socket Path=
6 Oct 12:01:30 - [trace] [uibuilder:Module] Using master src folder
6 Oct 12:01:30 - [trace]                    Reason for not using master dist folder:
6 Oct 12:01:30 - [info] +-----------------------------------------------------
6 Oct 12:01:30 - [info] | uibuilder initialised:
6 Oct 12:01:30 - [info] |   root folder: \Users\ramon\.node-red\uibuilder
6 Oct 12:01:30 - [info] |   version . .: 2.0.4
6 Oct 12:01:30 - [info] |   packages . : vue,bootstrap,bootstrap-vue,socket.io
6 Oct 12:01:30 - [info] +-----------------------------------------------------
6 Oct 12:01:30 - [info] Dashboard version 2.16.3 started at /ui
6 Oct 12:01:31 - [red] Uncaught Exception:
6 Oct 12:01:31 - TypeError: cb.apply is not a function
    at C:\Users\ramon\.node-red\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
    at FSReqCallback.oncomplete (fs.js:166:5)

With npm ls graceful-fs, the output was:

node-red-project@0.0.1 C:\Users\ramon\.node-red
+-- graceful-fs@4.2.2
+-- node-red-contrib-function-npm@0.3.0
| `-- npm@5.10.0
|   +-- bin-links@1.1.0
|   | `-- graceful-fs@4.1.11  deduped
|   +-- cacache@10.0.4
|   | `-- graceful-fs@4.1.11  deduped
|   +-- cmd-shim@2.0.2
|   | `-- graceful-fs@4.1.11  deduped
|   +-- fs-vacuum@1.2.10
|   | `-- graceful-fs@4.1.11  deduped
|   +-- fs-write-stream-atomic@1.0.10
|   | `-- graceful-fs@4.1.11  deduped
|   +-- gentle-fs@2.0.1
|   | `-- graceful-fs@4.1.11  deduped
|   +-- graceful-fs@4.1.11
|   +-- libcipm@1.6.2
|   | `-- graceful-fs@4.1.11  deduped
|   +-- node-gyp@3.6.2
|   | +-- fstream@1.0.11
|   | | `-- graceful-fs@4.1.11  deduped
|   | `-- graceful-fs@4.1.11  deduped
|   +-- npm-lifecycle@2.0.1
|   | `-- graceful-fs@4.1.11  deduped
|   +-- npm-registry-client@8.5.1
|   | `-- graceful-fs@4.1.11  deduped
|   +-- read-cmd-shim@1.0.1
|   | `-- graceful-fs@4.1.11  deduped
|   +-- read-installed@4.0.3
|   | `-- graceful-fs@4.1.11  deduped
|   +-- read-package-json@2.0.13
|   | `-- graceful-fs@4.1.11  deduped
|   +-- readdir-scoped-modules@1.0.2
|   | `-- graceful-fs@4.1.11  deduped
|   +-- sha@2.0.1
|   | `-- graceful-fs@4.1.11  deduped
|   +-- update-notifier@2.5.0
|   | `-- configstore@3.1.2
|   |   `-- graceful-fs@4.1.11  deduped
|   `-- write-file-atomic@2.3.0
|     `-- graceful-fs@4.1.11  deduped
`-- node-red-contrib-uibuilder@2.0.4
  `-- fs-extra@8.1.0
    +-- graceful-fs@4.2.2  deduped
    `-- jsonfile@4.0.0
      `-- graceful-fs@4.2.2  deduped
TotallyInformation commented 5 years ago

OK, interesting, I think I may have seen the issue.

Could you please remove the node-red-contrib-npm node? I think that is the one actually causing the issue rather than uibuilder but lets see if I'm right.

ramonneves commented 5 years ago

Do you mean from node_modules folder, package.json or somewhere else? In the folder or package.json there is no package with such name.

Here is the folder with contrib: image

And the json package: { "name": "node-red-project", "description": "A Node-RED Project", "version": "0.0.1", "private": true, "dependencies": { "graceful-fs": "^4.2.2", "node-red-contrib-ads": "~1.1.22", "node-red-contrib-function-npm": "~0.3.0", "node-red-contrib-mic": "0.0.1", "node-red-contrib-opcua": "~0.2.49", "node-red-contrib-s7": "~2.0.2", "node-red-contrib-tciot": "~0.9.7", "node-red-contrib-uibuilder": "~2.0.4", "node-red-dashboard": "~2.16.3", "node-red-node-email": "~1.7.1", "node-red-node-rbe": "~0.2.5", "node-red-node-sqlite": "~0.3.7", "node-red-node-tail": "0.0.3" } }

TotallyInformation commented 5 years ago

node-red-contrib-function-npm

That is the node that I think is causing the issue. You should be able to remove it using Node-RED's palette manager or by doing npm remove node-red-contrib-function-npm from your userDir.

ramonneves commented 5 years ago

That is it! Thank you! Are you considering this a uibuilder bug?

TotallyInformation commented 5 years ago

Hi, no - this is a function-npm bug, please do report it to them. I've seen this node causing issues before. There are 2 immediate indicators that it was that node:

If trying to use npm programatically, applications should execute the command and not try to use it as a module. uibuilder calls npm via an exec function to avoid these issues. That way, we have the correct version for the version of node.js that is installed on the host system and we avoid any issues caused by internal changes to npm.

Closing this for now, please feel free to raise new issues as you find them.

TotallyInformation commented 5 years ago

I've raised an issue on function-npm:

https://github.com/ntsaini/node-red-contrib-function-npm/issues/20