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

**URL:** https://discourse.nodered.org/t/typeerror-cannot-read-properties-of-undefined-reading-hasownproperty/97867
**Category:** General
**Tags:** docker
**Created:** [30 June 2025 02:41 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-properties-of-undefined-reading-hasownproperty/97867 "2025-06-30T02:41:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![bigbean17](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bigbean17/32/89814_2.png) [@bigbean17](https://discourse.nodered.org/u/bigbean17)
#### Post date: [30 June 2025 02:41 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-properties-of-undefined-reading-hasownproperty/97867/1 "2025-06-30T02:41:42Z")

</div>

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:

```auto
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

```auto
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

```auto

# 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

```auto
[
    {
        "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"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [30 June 2025 06:51 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-properties-of-undefined-reading-hasownproperty/97867/2 "2025-06-30T06:51:48Z")

</div>

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.

> [@bigbean17](#):
>
> This time, the project selection dialog stays stuck, and I see a warning like `undefined:undefined` in the UI.

please capture a screenshot

> [@bigbean17](#):
>
> I restart the container one more time, and everything works normally.

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.

---

<div class="post-metadata">

### Author: ![bigbean17](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bigbean17/32/89814_2.png) [@bigbean17](https://discourse.nodered.org/u/bigbean17)
#### Post date: [1 July 2025 23:05 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-properties-of-undefined-reading-hasownproperty/97867/3 "2025-07-01T23:05:50Z")

</div>

Hi @Steve-Mcl,

> 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.

Seems you are right, I regenerated all the files and folders by creating a project from scratch fixed the problem.

Thank you!

---

<div class="post-metadata">

### Author: ![Anmirazik](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/anmirazik/32/87890_2.png) [@Anmirazik](https://discourse.nodered.org/u/Anmirazik)
#### Post date: [14 July 2025 13:29 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-properties-of-undefined-reading-hasownproperty/97867/4 "2025-07-14T13:29:15Z")

</div>

> [@bigbean17](#):
>
> Seems you are right, I regenerated all the files and folders by creating a project from scratch fixed the problem.

Hey i'm having the same exact issues as you and two times restart fixed the problem just like you are

[bigbean17](https://discourse.nodered.org/u/bigbean17) erm , may i know what do you mean by regenerated all the files and folders and start from scratch ?

As for my case , I mount the /data/projects to host filesystem and then i try to restore it from the backup volumes that i mount but i need to do restart two times to make it render the flows , could you please advice what do you mean by regenerating all the files back ? do you manage to make it work with docker ?

---

<div class="post-metadata">

### Author: ![bigbean17](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bigbean17/32/89814_2.png) [@bigbean17](https://discourse.nodered.org/u/bigbean17)
#### Post date: [22 July 2025 21:50 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-properties-of-undefined-reading-hasownproperty/97867/5 "2025-07-22T21:50:16Z")

</div>

> [@Anmirazik](#):
>
> all

Hi,  
Sorry for the late reply.

Yes, I regenerated everything from scratch (installing node-red, enable projects and copy-paste all the my flows.)

Yes, it works with Docker. There is a node-red docker example, I started from there, to verify it is not the issue with node-red or docker itself. Then, you regenerate all the files and add them to the docker. If that works well, copy-paste your existing flows to the fresh node-red instance and install all the missing dependencies. It should be work afterwards.

Hope it helps.

---

<div class="post-metadata">

### Author: ![bigbean17](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bigbean17/32/89814_2.png) [@bigbean17](https://discourse.nodered.org/u/bigbean17)
#### Post date: [22 July 2025 22:38 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-properties-of-undefined-reading-hasownproperty/97867/6 "2025-07-22T22:38:42Z")

</div>

And from what I found, it seems like the issue was caused by the file `.config.projects.json` is missing. I ignored all the .config except that file and everything works fine now.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [5 August 2025 22:38 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-properties-of-undefined-reading-hasownproperty/97867/7 "2025-08-05T22:38:48Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
