TypeError: fg.convertPathToPattern is not a function

Versions:

Node-RED: v4.0.9
Node.js: v20.19.4
node-red-contrib-uibuilder@7.4.3

Issue:

I've had Node-RED running on Node.js v18 for a while now, with the last uibuilder update being 6.8.2 (if the file I'm looking at is correct). I decided to go ahead with upgrading to Node.js v20 because of the errors I was getting in npm about lack of support. The upgrade went fine and all of my nodes seemed to update cleanly, except for node-red-contrib-uibuilder.

I updated node-red-contrib-uibuilder to the latest version using Manage Palette and restarted Node-RED. After that, I found that my UIs were returning "Cannot GET /urlhere/". When I opened the admin view, I saw that there wasn't a "connected <#>" status under the node like there usually is. I attached a debug node and deployed. I got an error (uncaught by the catch:all error node on that tab) saying "TypeError: fg.convertPathToPattern is not a function", and the uibuilder node now had a blue status dot underneath saying "Configuring node".

I looked up convertPathToPattern in the package it's said to come from (fast-glob) and found it mentioned there, so I'm not sure why it says it doesn't exist, unless that function isn't publicly accessible.

What did I break, and how do I fix it?

EDIT: for later readers, the initial issue was solved by making a copy of my uibuilder folder and exporting a copy of my uibuilder node (i only use one), then uninstalling uibuilder in Manage Palette, then using node-red-restart, then reinstalling uibuilder, then making a new uibuilder node as a near-exact copy of the old one (the only difference being an internal read-only version number variable used for debugging). After this, I was able to copy in my old html/css/js/image files and get the page to open again, but still had other issues tht were solved starting at the solution below.

An error like that often means that fg is not what it should be.

I opened the packagejson and found that the expected versions matched. A rebuild of fast-glob and node-red-contrib-uibuilder didn't seem to faze it, either.

Also, I've noticed now that, in the palette, I'm being given the option to remove uibuilder, despite it being in use in one of my flows (perhaps because it's not getting past configuration, but I wouldn't expect that to be interpreted as a missing node).

Hi, are you getting any errors in the Node-RED Log? If so, can you please share them?

When you upgraded node.js, did you do a rebuild of your nodes? It is not uncommon for a major upgrade of node.js to require you to do that.

cd ~/.node-red
npm rebuild

As for what you are seeing in Node-RED's palette - there is a bug in all versions of Node-RED that fails to correctly show what nodes are present if there is a mix of nodes and plugins:

On v4.0.9:

On v4.1.0-beta2:

Node-RED log is minimal:

I also made a backup of the uibuilder folder (and the node i had in the flow), uninstalled uibuilder, restarted Node-RED, reinstalled uibuilder, and remade the node (I did a diff check and found that they were both the same, except one had a deployedVersion of 5.0.2 while the new one had 7.4.3). Instead of returning "Cannot GET /urlhere/", it returns the page that I wanted to see, albeit without loading the SVG's inputs properly.

Using npm rebuild causes this:

npm error code 1
npm error path /home/NAMEHERE/.node-red/node_modules/cpu-features
npm error command failed
npm error command sh -c node buildcheck.js > buildcheck.gypi && node-gyp rebuild
npm error make: Entering directory '/home/NAMEHERE/.node-red/node_modules/cpu-features/build'
npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_aarch64_linux_or_android.o
npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_arm_linux_or_android.o
npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_mips_linux_or_android.o
npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_ppc_linux.o
npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_freebsd.o
npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_linux_or_android.o
npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_macos.o
npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_windows.o
npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/filesystem.o
npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/stack_line_reader.o
npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/string_view.o
npm error rm -f Release/obj.target/deps/cpu_features/cpu_features.a Release/obj.target/deps/cpu_features/cpu_features.a.ar-file-list; mkdir -p `dirname Release/obj.target/deps/cpu_features/cpu_features.a`
npm error ar crs Release/obj.target/deps/cpu_features/cpu_features.a @Release/obj.target/deps/cpu_features/cpu_features.a.ar-file-list
npm error   COPY Release/cpu_features.a
npm error   CXX(target) Release/obj.target/cpufeatures/src/binding.o
npm error make: Leaving directory '/home/NAMEHERE/.node-red/node_modules/cpu-features/build'
npm error gyp info it worked if it ends with ok
npm error gyp info using node-gyp@11.2.0
npm error gyp info using node@20.19.4 | linux | x64
npm error gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
npm error gyp info spawn /usr/bin/python3
npm error gyp info spawn args [
npm error gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '-f',
npm error gyp info spawn args 'make',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/NAMEHERE/.node-red/node_modules/cpu-features/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/root/.cache/node-gyp/20.19.4/include/node/common.gypi',
npm error gyp info spawn args '-Dlibrary=shared_library',
npm error gyp info spawn args '-Dvisibility=default',
npm error gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/20.19.4',
npm error gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
npm error gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/20.19.4/<(target_arch)/node.lib',
npm error gyp info spawn args '-Dmodule_root_dir=/home/NAMEHERE/.node-red/node_modules/cpu-features',
npm error gyp info spawn args '-Dnode_engine=v8',
npm error gyp info spawn args '--depth=.',
npm error gyp info spawn args '--no-parallel',
npm error gyp info spawn args '--generator-output',
npm error gyp info spawn args 'build',
npm error gyp info spawn args '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error gyp info spawn make
npm error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm error In file included from ../../nan/nan.h:180,
npm error                  from ../src/binding.cc:3:
npm error ../../nan/nan_callbacks.h:55:23: error: ‘AccessorSignature’ is not a member of ‘v8’
npm error    55 | typedef v8::Local<v8::AccessorSignature> Sig;
npm error       |                       ^~~~~~~~~~~~~~~~~
npm error ../../nan/nan_callbacks.h:55:40: error: template argument 1 is invalid
npm error    55 | typedef v8::Local<v8::AccessorSignature> Sig;
npm error       |                                        ^
npm error In file included from ../src/binding.cc:1:
npm error /root/.cache/node-gyp/20.19.4/include/node/node.h:1227:43: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
npm error  1227 |       (node::addon_register_func) (regfunc),                          \
npm error       |                                           ^
npm error /root/.cache/node-gyp/20.19.4/include/node/node.h:1261:3: note: in expansion of macro ‘NODE_MODULE_X’
npm error  1261 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
npm error       |   ^~~~~~~~~~~~~
npm error ../src/binding.cc:152:1: note: in expansion of macro ‘NODE_MODULE’
npm error   152 | NODE_MODULE(cpufeatures, init)
npm error       | ^~~~~~~~~~~
npm error make: *** [cpufeatures.target.mk:119: Release/obj.target/cpufeatures/src/binding.o] Error 1
npm error gyp ERR! build error 
npm error gyp ERR! stack Error: `make` failed with exit code: 2
npm error gyp ERR! stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:219:23)
npm error gyp ERR! System Linux 5.15.0-139-generic
npm error gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm error gyp ERR! cwd /home/NAMEHERE/.node-red/node_modules/cpu-features
npm error gyp ERR! node -v v20.19.4
npm error gyp ERR! node-gyp -v v11.2.0
npm error gyp ERR! not ok
npm error A complete log of this run can be found in: /root/.npm/_logs/2025-07-22T20_09_15_695Z-debug-0.log

That isn't the node red log. Try
sudo journalctl -f -n 100 -u nodered -o cat

When posting logs please copy/paste rather than screenshot.

So looks like you are going from uibuilder v5 to v7 so do check out the breaking changes between them. 5 -> 6 did have some changes that you need to deal with in your html file.

Quite likely the major node.js upgrade issue.

Make sure that you have the build tools installed so that npm can do rebuild of binary libraries for node.js.

So looks like you are going from uibuilder v5 to v7 so do check out the breaking changes between them. 5 -> 6 did have some changes that you need to deal with in your html file.

It looks like this was the issue. In the jump from 6 to 7, I needed to switch from uibuilderfe.min.js to uibuilder.iife.min.js and remove socket.io.js. Thank you for this, it's running cleanly now.

Make sure that you have the build tools installed so that npm can do rebuild of binary libraries for node.js.

I checked and I have it installed, it just doesn't seem to want to cooperate on cpufeatures. It looks like it still runs regardless, though.

Hopefully, the days of such issues are behind us now - at least for some while. The old client library is gone for good and the new library is much simpler to use. v7 cleared out a backlog of changes that might have been breaking for a few people. The next major upgrade is likely to only really have an impact on the minimum node.js version and will likely happen in line with Node-RED upgrading to v5.

Not sure if it is good to reply here but I am getting the exact same error:

[error] [uibuilder:d997a40a5731934a] TypeError: fg.convertPathToPattern is not a function

Upgraded the following:
Node-RED: v4.0.9 → v4.1.0
Node.js: v20.19.3 → v20.19.4
node-red-contrib-uibuilder@7.4.1 → 7.4.3

I already did the ‘npm rebuild’. In NodeRED it says “Configuring node” below the uibulder nodes and when I change something I am getting the Error ‘fg.convertPathToPattern' in the NodeRED Debug area. When I try to access the Website-URL I only get a ‘Cannot GET /website/’ message.

EDIT: I had to do the same thing to fix this issue:

You only need to rebuild when switching node.js major versions.

We really need to see more of the logs in order to make sense of them.

Do you mean in the Editor or in the node-red log - if in the Editor, if you expand the error message, we can get a full traceback of where the issue comes from.

Yes, uibuilder has not been able to mount your instance endpoint to ExpressJS.


I don’t really have enough to go on to be able to reproduce the error from what you’ve shared.

This error message was the only Error in ‘node-red-log’ when I started up NodeRED.

Whenever I changed something on the existing uibuilder-Node (e.g. just move it around and re-deploy) in the NodeRED Editor then the message that also mentioned something with an ‘fg.convertPathToPattern error’ appeared in the NodeRED Editor Debug window.

Unfortunately I didn’t expand this message and I directly went on to try the hint from the thread creator (remove and reinstall uibuilder), which fixed the error. :laughing:

Theres maybe one more interesting detail. If I now check the GIT version control history, there is only one single change for the uibuilder-node (that I imported back in my flow): deployedVersion was ‘5.1.1’ before and now “7.4.3”. Thats a bit strange as I was using uibuilder 7.4.1 before. Maybe just that variable didn’t get updated.

Anyway, everything is working again now. :slightly_smiling_face: It was just a bit strange, as I've never had to reinstall uibuilder after an update before.

OK, thanks for the update anyway.

That line of code was contributed by someone else and was merged in 3 weeks ago. It was a change to make the fgSync function in fs.cjs work correctly on Windows. It is only used in 1 place. The fgSync function is only called in 2 places in the web.cjs library. Once to add the instance API route (<uibRoot>/<node.url>/api/*.js) and once to add any instance custom routes (<uibRoot>/<node.url>/routes/*.js) - neither of which are commonly used by people.

Are you running on Windows or Linux?

I am running it on a Raspberry Pi 4 (Linux 6.12.34+rpt-rpi-v8)