# Console: Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

**Code:** `Failed to execute on 'Node'` · **Category:** Browser · **Seen on:** Chrome, Firefox, Safari, JavaScript

A DOM method received something that is not a DOM node — `null`, `undefined`, a string, or a jQuery/React object instead of an element.

## Meaning

`appendChild`, `insertBefore`, `replaceChild` and similar need real `Node` objects. The usual cause is a failed lookup (`getElementById` returned `null` because the element did not exist yet) or passing a string where an element is needed (use `append()` or `insertAdjacentHTML`).

## Common causes

- `document.getElementById` / `querySelector` returned `null` (wrong id, script runs before the DOM is ready)
- Passing a string, number or array instead of an element
- Passing a jQuery object (`$('#x')`) instead of the DOM element (`$('#x')[0]`)
- Element created in another document/iframe
- Typo in a variable name

## Quick fix

1. Check that the element exists before using it (`if (el) …`)
2. Run code after DOMContentLoaded or put the script at the end of `<body>`
3. Use `el.append('text')` for strings

## Detailed fix by platform

### JavaScript

1. `const el = document.getElementById('list'); if (!el) throw new Error('#list not found'); el.appendChild(li);`
2. For text: `el.append('Hello')`

## Code examples

### Run after the DOM exists

```javascript
document.addEventListener('DOMContentLoaded', () => {
  const list = document.querySelector('#list');
  if (!list) return;                           // avoid the TypeError
  const li = document.createElement('li');
  li.textContent = 'New item';
  list.appendChild(li);                        // both arguments are real Nodes
});
```

## How to diagnose

1. **Value** — Is the argument null or the wrong type?
2. **Timing** — Is the DOM ready?
3. **Selector** — Does the id/class exist?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/browser/failed-to-execute-on-node)
