# Error: Cannot find module 'mqtt'

**URL:** https://discourse.nodered.org/t/error-cannot-find-module-mqtt/48581
**Category:** General
**Created:** [19 July 2021 11:01 UTC](https://discourse.nodered.org/t/error-cannot-find-module-mqtt/48581 "2021-07-19T11:01:55Z")
**Posts on this page:** 1
**Showing post:** 4

<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: [19 July 2021 11:44 UTC](https://discourse.nodered.org/t/error-cannot-find-module-mqtt/48581/4 "2021-07-19T11:44:01Z")

</div>

> [@Xecu114](#):
>
> npm install mqtt --save

From inside your custom node path?

> [@Xecu114](#):
>
> npm install mqtt -g

Dont do that.

> [@Xecu114](#):
>
> and if i look for mqtt it is listed both in my project folder as in the global folder.

Because you did `npm install mqtt -g`

* * *

You should simply...

- Setup your custom nodes project folder with necessary files (package.json, your-node.js, your-node.html)
- For any module that is required by your contrib node, from the base path of your custom node (e.g. `C:\my-projects\my-contrib-node`) install the requires using `npm -i mqtt` (or whatever)
- Ensure your project folder has a `.gitignore` file and exclude `node_modules` etc

Once project is ready to test, in your node-red folder (e.g. `cd c:\users\JSHR\.node-red`), install your node...

- `npm install C:/my-projects/my-contrib-node`

Restart node-red after every change to your source.

* * *

From that point on, `C:/my-projects\my-contrib-node` will be sym-linked to `c:\users\JSHR\.node-red\node_modules\my-contrib-node`. That means any files you change/delete in `c:\users\JSHR\.node-red\node_modules\my-contrib-node` will be changed/deleted from `C:/my-projects\my-contrib-node`

* * *

alternatively, if you want step debug in vscode - [follow this](https://discourse.nodered.org/t/how-to-proper-debug-custom-node/9308/13)

---

_[View the full topic](https://discourse.nodered.org/t/error-cannot-find-module-mqtt/48581)._
