TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')

Hi all,

I'm trying to deploy my Node-RED app (with projects enabled) using Docker, but I keep running into this error on first launch:

TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')

My goal is to have the project load automatically. Here's what happens:

  1. I pull the latest image and run the container.
  2. On first launch, Node-RED asks me for my username and email, then prompts me to select a project (my project appears in the list).
  3. After selecting the project, the error above occurs in the logs docker logs <container-name>
  4. I then restart the container. It asks for username and email again, and prompts for project selection. This time, the project selection dialog stays stuck, and I see a warning like undefined:undefined in the UI.
  5. I restart the container one more time, and everything works normally.

This happens every time I pull a new image and start fresh.

Any ideas on what might be causing this or how to avoid it?

Thanks in advance!

=== Files ===

The settings.js

module.exports={
  "flowFile": "flows.json",
  "flowFilePretty": true,
  "uiPort": 1880,
  "diagnostics": {
      "enabled": true,
      "ui": true
  },
  "runtimeState": {
      "enabled": false,
      "ui": false
  },
  "logging": {
      "console": {
          "level": "info",
          "metrics": false,
          "audit": false
      }
  },
  "exportGlobalContextKeys": false,
  "externalModules": {},
  "editorTheme": {
      "palette": {},
      "projects": {
          "enabled": true,
          "workflow": {
              "mode": "manual"
          },
          "activeProject": "app"
      },
      "codeEditor": {
          "lib": "monaco",
          "options": {}
      },
      "markdownEditor": {
          "mermaid": {
              "enabled": true
          }
      },
      "multiplayer": {
          "enabled": false
      }
  },
  "functionExternalModules": true,
  "functionTimeout": 0,
  "functionGlobalContext": {},
  "debugMaxLength": 1000,
  "mqttReconnectTime": 15000,
  "serialReconnectTime": 15000,
  "credentialSecret": “test”
}

The Dockerfile



# Use official Node-RED base image
FROM nodered/node-red:latest

LABEL maintainer="a@a.com"
LABEL description="Test project”

WORKDIR /usr/src/node-red

# Copy your settings.js file into the image
COPY --chown=1000:1000 settings.js /data/settings.js

# Copy project files into the image
COPY --chown=1000:1000 projects/app/ /data/projects/app/

# Set working dir to /data (Node-RED's persistent volume)
WORKDIR /data

# Install custom modules from package.json
COPY --chown=1000:1000 package.json /data/projects/app/package.json
RUN npm install --unsafe-perm --no-update-notifier --no-fund || true

WORKDIR /data/projects/app

RUN git init && \
    git config user.email "node-red@container.local" && \
    git config user.name "Node-RED Container" && \
    git config init.defaultBranch main && \
    git add . && \
    git commit -m "Initial project state from image build"

WORKDIR /usr/src/node-red

The flow

[
    {
        "id": "53492c37305c2edf",
        "type": "tab",
        "label": "Flow 3",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "8e743462ef6db302",
        "type": "inject",
        "z": "53492c37305c2edf",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "HELLO DOCKER",
        "payloadType": "str",
        "x": 240,
        "y": 560,
        "wires": [
            [
                "f1eb0dc21bfdbebb"
            ]
        ]
    },
    {
        "id": "4762323407a4dea0",
        "type": "debug",
        "z": "53492c37305c2edf",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 820,
        "y": 520,
        "wires": []
    },
    {
        "id": "f1eb0dc21bfdbebb",
        "type": "function",
        "z": "53492c37305c2edf",
        "name": "HELLO FROM DOCKER COMPOSE",
        "func": "msg.payload = \"HELLO FROM DOCKER COMPOSE\"\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 530,
        "y": 560,
        "wires": [
            [
                "4762323407a4dea0"
            ]
        ]
    }
]

There will likely be more than just TypeError: Cannot read properties of undefined (reading 'hasOwnProperty') perhaps a stack trace or at least the log entries before and after it (so we can see what part of the loading phase it occurs or any other errors/warnings for contextual purposes)

FWIW, your settings file works on a clean Node-RED 4.1.0 beta.2 (after a changed the "credentialSecret": “test” to "credentialSecret": "test" (bad quotes) and I can create a project.

please capture a screenshot

This suggests not everything was in place correctly (some files missing? or different values?) and a few restarts has allowed it to sort itself out. I am not saying this is expected or right, just what appears to be happening. So, I would suggest forget docker for a moment, install Node-RED natively and run it with your settings.js, create an project named app and then make sure you capture all files from the .node-red dir (especially creds & config json files) and make sure they are copied to your docker container.