# Error: Cannot find module '@abandonware/noble'

**URL:** <https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421>\
**Category:** Developing Nodes\
**Created:** [19 October 2021 15:10 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421 "2021-10-19T15:10:32Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [19 October 2021 15:10 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/1 "2021-10-19T15:10:32Z")

</div>

Hi,

I am trying to run my customized node on **Raspberry Pi 4** that runs **DietPi OS**. But, I am having errors along the way. I have tried many different things, but no success yet.

The main error that I would like to fix is **the one in the title**. However, as I am not sure what is the exact reason, I would like to include the errors I got along the way.

The following installation script does not work on **DietPi** :

```auto
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

```

So, I install `node.js` and `node-red` via using their recommended script (`dietpi-software`).

After installation finishes, I run `npm doctor` and got the following:

```auto
npm WARN checkFilesPermission error getting info for /usr/bin/node_modules
npm WARN checkFilesPermission error getting info for /usr/bin/node_modules/.bin
Check Value Recommendation/Notes
npm ping ok
npm -v not ok Use npm v8.1.0
node -v ok current: v16.11.1, recommended: v16.11.1
npm config get registry ok using default registry (https://registry.npmjs.org/)
which git ok /usr/bin/git
Perms check on cached files ok
Perms check on local node_modules not ok Check the permissions of files in /usr/bin/node_modules (should be owned by current user)
Perms check on global node_modules ok
Perms check on local bin folder not ok Check the permissions of files in /usr/bin/node_modules/.bin
Perms check on global bin folder ok
Verify cache contents ok verified 347 tarballs

npm ERR! Some problems found. See above for recommendations.

```

My customized package depends on [@abandonware/noble](https://www.npmjs.com/package/@abandonware/noble). Hence, first, I install its dependencies:

`sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev`

Then, I install the **@abandonware/noble** package. This one should be done in `/mnt/dietpi_userdata/node-red`, otherwise will not work. So I run the following:  
`sudo npm i @abandonware/noble`

If I do not install as root I get the following error:

`Error: EACCES: permission denied, mkdir '/mnt/dietpi_userdata/node-red/node_modules/@abandonware'`

Installation finishes without any error.

```auto
added 11 packages, and audited 306 packages in 47s

27 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

```

Then, I run Node-RED just to see if everything is fine:  
`dietpi-services start node-red`.  
I am actually running it as `node-red-start` as I am very used to it. To see how it is done please see the following [discussion.](https://discourse.nodered.org/t/dietpi-installation-lacks-basic-commands/10388/8) Here is the Node-RED log that I believe it is pretty normal:

```auto
19 Oct 14:38:36 - [info] Node-RED version: v2.0.6
19 Oct 14:38:36 - [info] Node.js version: v16.11.1
19 Oct 14:38:36 - [info] Linux 5.10.63-v8+ arm64 LE
19 Oct 14:38:37 - [info] Loading palette nodes
19 Oct 14:38:39 - [info] Settings file : /mnt/dietpi_userdata/node-red/settings.js
19 Oct 14:38:39 - [info] Context store : 'default' [module=memory]
19 Oct 14:38:39 - [info] User directory : /mnt/dietpi_userdata/node-red
19 Oct 14:38:39 - [warn] Projects disabled : editorTheme.projects.enabled=false
19 Oct 14:38:39 - [info] Flows file : /mnt/dietpi_userdata/node-red/flows.json
19 Oct 14:38:39 - [info] Creating new flow file
19 Oct 14:38:40 - [warn]

```

Then, I stop Node-RED and install my customized package inside `/mnt/dietpi_userdata/node-red`.  
`sudo npm install /home/dietpi/node-red-contrib-ble-sense`.

Then I run the Node-RED. But this time, I am getting an error:

```auto
19 Oct 15:50:00 - [warn] [node-red-contrib-ble-sense/protocols] Error: Cannot find module '@abandonware/noble'
Require stack:
- /home/dietpi/node-red-contrib-ble-sense/ble.js
- /mnt/dietpi_userdata/node-red/node_modules/@node-red/registry/lib/loader.js
- /mnt/dietpi_userdata/node-red/node_modules/@node-red/registry/lib/index.js
- /mnt/dietpi_userdata/node-red/node_modules/@node-red/runtime/lib/nodes/index.js
- /mnt/dietpi_userdata/node-red/node_modules/@node-red/runtime/lib/index.js
- /mnt/dietpi_userdata/node-red/node_modules/node-red/lib/red.js
- /mnt/dietpi_userdata/node-red/node_modules/node-red/red.js

```

The thing that I believe it might be related to the problem.

- The `/mnt` is owned by the root: `drwxr-xr-x 6 root root 4096 Aug 12 15:16 mnt`
- I can see the @abandonware/noble package in `package.json`.

```auto
  "dependencies": {
    "@abandonware/noble": "^1.9.2-14",
    "node-red": "^2.0.6",
    "node-red-contrib-ble-sense": "file:../../../home/dietpi/node-red-contrib-ble-sense"
  }

```

- I can see the `@abandonware/noble` and `node-red-contrib-ble-sense` in `/mnt/dietpi_userdata/node-red/node_modules`.
- Symbolic link is created for `node-red-contrib-ble-sense` and owned by the root.  
`lrwxrwxrwx 1 root root 50 Oct 19 15:47 node-red-contrib-ble-sense -> ../../../../home/dietpi/node-red-contrib-ble-sense`. I realized all other packages are owned by `nodered` and belong to the group `nodered`.
- The `/home/dietpi/node-red-contrib-ble-sense` is owned by `dietpi` and belong to the `dietpi` group
- `dietpi` is only included in `dietpi` group.

I developed that package via the Raspberry Pi OS without any issues. I would like to continue the development in DietPi for other reasons. I appreciate any feedback.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [19 October 2021 23:24 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/2 "2021-10-19T23:24:31Z")

</div>

> [@hkayan](#):
>
> `sudo npm i @abandonware/noble`
> 
> If I do not install as root I get the following error:
> 
> `Error: EACCES: permission denied, mkdir '/mnt/dietpi_userdata/node-red/node_modules/@abandonware'`

Your problem is clearly highlighted here. You have mixed up permissions and so will now be suffering.

You should not be installing npm modules with `sudo` generally.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [20 October 2021 12:09 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/3 "2021-10-20T12:09:22Z")

</div>

I tried installing via nvm as it is recommended in many places, still no luck.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [20 October 2021 13:09 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/4 "2021-10-20T13:09:15Z")

</div>

Apparently I was running `npm doctor` from a [wrong path](https://dietpi.com/phpbb/viewtopic.php?p=38972#p38972). Now `npm doctor` generated all OKs.

However `npm install` asked for permissions again.

Then I followed the instructions mentioned [here.](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)

Now, I can install nodes without root permission. I will test developing customized node now.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 October 2021 14:13 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/5 "2021-10-20T14:13:24Z")

</div>

> [@hkayan](#):
>
> I tried installing via nvm as it is recommended in many places, still no luck.

Honestly, it is best to steer away from node version managers, they tend to cause more issues than they resolve.

> [@hkayan](#):
>
> However `npm install` asked for permissions again.

You will need to sort out the permissions in the folders because those may already be messed up.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [20 October 2021 14:17 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/6 "2021-10-20T14:17:18Z")

</div>

Hi @TotallyInformation,

I did the fresh install, then applied the fix that I gave a link in my above post. Now I can install nodes without root permission.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 October 2021 14:30 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/7 "2021-10-20T14:30:22Z")

</div>

As always, the rule is - don't use sudo unless you really need to.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [20 October 2021 16:55 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/8 "2021-10-20T16:55:57Z")

</div>

I am still getting the error of `Error: Cannot find module ‘@abandonware/noble’` when I install my custom node and run Node-RED. However, I have a new lead, I am getting this warning now:

```auto
(node:12996) [DEP0128] DeprecationWarning: Invalid 'main' field in '/mnt/dietpi_userdata/node-red/node_modules/@node-red/editor-client/package.json' of './lib/index.js'. Please either fix that or report it to the module author
(Use `node --trace-deprecation ...` to show where the warning was created)

```

If I check that field, it is

```auto
{
    "name": "@node-red/editor-client",
    "version": "2.0.6",
    "license": "Apache-2.0",
    "repository": {
        "type": "git",
        "url": "https://github.com/node-red/node-red.git"
    },
    "contributors": [
        {
            "name": "Nick O'Leary"
        },
        {
            "name": "Dave Conway-Jones"
        }
    ],
    "main": "./lib/index.js"
}

```

Maybe @knolleary can help with this.  
Also, here is log of my main error, that I am trying to solve:

```auto
[warn] [node-red-contrib-ble-sense/protocols] Error: Cannot find module '@abandonware/noble'
Require stack:
- /home/dietpi/node-red-contrib-ble-sense/ble.js
- /mnt/dietpi_userdata/node-red/node_modules/@node-red/registry/lib/loader.js
- /mnt/dietpi_userdata/node-red/node_modules/@node-red/registry/lib/index.js
- /mnt/dietpi_userdata/node-red/node_modules/@node-red/runtime/lib/nodes/index.js
- /mnt/dietpi_userdata/node-red/node_modules/@node-red/runtime/lib/index.js
- /mnt/dietpi_userdata/node-red/node_modules/node-red/lib/red.js
- /mnt/dietpi_userdata/node-red/node_modules/node-red/red.js

```

Another lead that I have is, I have realized `~/.npm` is empty, but `~/.npm-global` has the modules.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [20 October 2021 17:02 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/9 "2021-10-20T17:02:17Z")

</div>

> [@hkayan](#):
>
> `DeprecationWarning: Invalid 'main' field`

That is just a warning when running with Node 16. It has been fixed in 2.1 but has absolutely no bearing on the issue you're experiencing.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [20 October 2021 18:29 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/10 "2021-10-20T18:29:21Z")

</div>

Alright. I am running Node-RED 17.0.0 though.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [20 October 2021 18:30 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/11 "2021-10-20T18:30:22Z")

</div>

> [@hkayan](#):
>
> I am running Node-RED 17.0.0 though.

The deprecation warning was introduced in Node 16.... so Node 17 has it as well.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [21 October 2021 13:42 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/12 "2021-10-21T13:42:22Z")

</div>

Oh, alright. `Node-RED version: v2.1.0` I am not getting that anymore as expected.

Now, the issue is the following:

```auto
[node-red-contrib-ble-sense/protocols] Error: EAFNOSUPPORT, Address family not supported by protocol

```

I have understood the [reason](https://stackoverflow.com/questions/13452224/possible-causes-of-errno-97-aka-eafnosupport-aka-address-family-not-supported-by). Now digging more to resolve this, sadly all examples I found are related to dockers.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [21 October 2021 15:14 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/13 "2021-10-21T15:14:55Z")

</div>

I was getting an error as I forgot to enable the bluetooth 😑. Now all works fine, I can finally start developing my package further 🤠.

TL:DR for how to develop your own node that depends on @abandonware/noble in DietPi.

- Install `node.js`, `node-red`, and `git` via `dietpi-software`.
- `cd` into `/mnt/dietpi_userdata/node-red`
- Run `sudo -u nodered npm doctor`. Get all OKs.
- Enable `bluetooth` via `dietpi-config`.
- Reboot.
- `cd` into `/mnt/dietpi_userdata/node-red` and install @abandonware/noble: `sudo -u nodered npm i @abandonware/noble`.
- Put your customized node folder in the same location as well.
- Then install your customized package `sudo -u nodered npm i /mnt/dietpi_userdata/node-red/mypackage.`
- Run node-red: `systemctl start node-red`.  
Now you should be able to see your custom node as well.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [25 October 2021 11:05 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/14 "2021-10-25T11:05:54Z")

</div>

Update: We also need to grant some privileges to node to do BLE/Bluetooth scan.

```auto
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

```

---

<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:** [8 November 2021 11:06 UTC](https://discourse.nodered.org/t/error-cannot-find-module-abandonware-noble/52421/15 "2021-11-08T11:06:55Z")

</div>

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