# Developing custom node in visual studio code

**URL:** <https://discourse.nodered.org/t/developing-custom-node-in-visual-studio-code/90232>\
**Category:** Developing Nodes\
**Created:** [17 August 2024 11:10 UTC](https://discourse.nodered.org/t/developing-custom-node-in-visual-studio-code/90232 "2024-08-17T11:10:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpadie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jpadie/32/87036_2.png) [@jpadie](https://discourse.nodered.org/u/jpadie)\
**Post date:** [17 August 2024 11:10 UTC](https://discourse.nodered.org/t/developing-custom-node-in-visual-studio-code/90232/1 "2024-08-17T11:10:20Z")

</div>

Hello all  
I'd like some assistance with getting an editor set up so that I can use auto-completion etc in visual studio code. I'm using mac OS.

I have my dev folder in home (~/nodeDev/matter).

I've installed the development into the node red via `npm install ~/nodeDev/matter` (from the .node-red folder).

the development is dependent on @project-chip/matter-node.js and I've installed this with `npm install @project-chip/matter-node.js --save`

so far so good.

The development is a mix of javascript and typescript. Where I am going wrong is when I try to import classes and variables into code. For example

`import { ServerNode } from "@project-chip/matter.js/node";`

results in an error "cannot find module '@project-chip/matter.js/node' or its corresponding type declarations."

the folder structure is

```auto

├── @project-chip
│ ├── matter-node.js
│ └── matter.js
├── node-red-contrib-matter.js -> ../../nodeDev/matter
│ ├── lib
│ └── src
├── signal-exit
│ └── dist
└── write-file-atomic
    └── lib

```

the file in development is in ../../nodeDev/matter/src

I suspect that something is awry with the package.json or the tsconfig.json files but must admit to being a newbie on both topics. any help gratefully received.

tsconfig.json

```auto
/* Dev configuration */
{
    "compilerOptions": {
        "module": "node16",
        "moduleResolution": "node16",
        "composite": true,
        "forceConsistentCasingInFileNames": true,
        "noImplicitAny": true,
        "noImplicitOverride": true,
        "noUnusedParameters": true,
        "noUnusedLocals": true,
        "strict": true,
        "outDir": "lib"
    },
    "include": [
        "src/*.ts",
        "src/*.js",
        "src/*.mjs",
    ],
    "allowJs": true
}

```

package.json

```auto
{
  "name": "node-red-contrib-matter.js",
  "version": "0.1.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "jpadie",
  "license": "ISC",
  "node-red": {
    "nodes": {
      "matter-thermostat-j": "src/thermostat.js",
      "matter-server-j": "src/server.js"
    }
  },
  "dependencies": {
    "@project-chip/matter-node.js": "^0.10.0"
  },
  "devDependencies": {
    "node-red": "^3.0.2"
  },
  "paths": {
    "*": [
      "/Users/jpadie/.node-red/node_modules/*",
      "*"
    ]
  }
}

```

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [17 August 2024 11:35 UTC](https://discourse.nodered.org/t/developing-custom-node-in-visual-studio-code/90232/2 "2024-08-17T11:35:33Z")

</div>

Hi @jpadie

I don't have any experience with this package - but, just firing up a quick edit, I was able to start the server.

It's `@project-chip/matter-node.js` not `@project-chip/matter.js/node`

```auto
const {MatterServer} = require("@project-chip/matter-node.js")

```

![Screenshot 2024-08-17 at 12.33.26](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/3/439b63d915185cc250c84aa983b291cfd85a718c.png)

 ![Screenshot 2024-08-17 at 12.36.13](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/9/095cc6dcd030b06234ccf2dbb154b2cae0474f3c.png)

> **[matter.js/packages/matter-node.js at main · project-chip/matter.js](https://github.com/project-chip/matter.js/tree/main/packages/matter-node.js)**
>
> A complete typescript implementation of the Matter protocol specification (https://buildwithmatter.com). Includes full support for controller, device, commissioning, secure communications, device t...

---

<div class="post-metadata">

**Author:** ![jpadie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jpadie/32/87036_2.png) [@jpadie](https://discourse.nodered.org/u/jpadie)\
**Post date:** [17 August 2024 11:51 UTC](https://discourse.nodered.org/t/developing-custom-node-in-visual-studio-code/90232/3 "2024-08-17T11:51:50Z")

</div>

thanks - I don't have an issue with the project-chip package, nor starting the server. I've done lots of development in that (and ServerNode is accessed via @project-chip/matter.js/node by the by, there are overlapping exports).

the challenge I am getting is the incorrect path resolution and associated lack of auto-completion.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [17 August 2024 12:03 UTC](https://discourse.nodered.org/t/developing-custom-node-in-visual-studio-code/90232/4 "2024-08-17T12:03:45Z")

</div>

Right, sorry - I probably don't know enough about the schematics of this matter project.  
I think there is a node that uses it however - by our very own @sammachin

> **[GitHub - sammachin/node-red-matter-bridge: Matter Bridge for Node-RED](https://github.com/sammachin/node-red-matter-bridge)**
>
> Matter Bridge for Node-RED

Might be a good resource?

---

<div class="post-metadata">

**Author:** ![jpadie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jpadie/32/87036_2.png) [@jpadie](https://discourse.nodered.org/u/jpadie)\
**Post date:** [17 August 2024 12:58 UTC](https://discourse.nodered.org/t/developing-custom-node-in-visual-studio-code/90232/5 "2024-08-17T12:58:40Z")

</div>

yup - there are a few projects using it, and I'm building another after fezvrasta has stopped maintaining his project.

I'm new to developing in these interpreted / semi-compiled languages though (although very experienced in php) and so am struggling with how to set up the package.json and tsconfig.json to make autocomplete and other extensions work in visual studio code.

When just developing within the project-chip ecosystem it works wonderfully. the challenge (for me) seems to be getting the IDE to work when there are multiple packages.

---

<div class="post-metadata">

**Author:** ![jpadie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jpadie/32/87036_2.png) [@jpadie](https://discourse.nodered.org/u/jpadie)\
**Post date:** [17 August 2024 13:50 UTC](https://discourse.nodered.org/t/developing-custom-node-in-visual-studio-code/90232/6 "2024-08-17T13:50:32Z")

</div>

thanks for your help. I have now resolved this by opening the developer environment at the .node-red folder rather than the development folder level. Perhaps obvious to those who are familiar!

---

<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:** [16 October 2024 13:50 UTC](https://discourse.nodered.org/t/developing-custom-node-in-visual-studio-code/90232/7 "2024-10-16T13:50:57Z")

</div>

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