# Error: Cannot find module 'i2c-bus'

**URL:** <https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259>\
**Category:** General\
**Created:** [28 November 2018 09:29 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259 "2018-11-28T09:29:53Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbreda007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jbreda007/32/6890_2.png) [@jbreda007](https://discourse.nodered.org/u/jbreda007)\
**Post date:** [28 November 2018 09:29 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/1 "2018-11-28T09:29:53Z")

</div>

New installion of node-red, but get the following error when trying to start it.

pi@jrbWork:~ $ node-red-start

Start Node-RED

Once Node-RED has started, point a browser at [http://192.168.1.201:1880](http://192.168.1.201:1880)  
On Pi Node-RED works better with the Firefox or Chrome browser

Use node-red-stop to stop Node-RED  
Use node-red-start to start Node-RED again  
Use node-red-log to view the recent log output  
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot  
Use sudo systemctl disable nodered.service to disable autostart on boot

To find more nodes and example flows - go to [http://flows.nodered.org](http://flows.nodered.org)

Starting as a systemd service.  
Started Node-RED graphical event wiring tool.  
Error loading settings file: /home/pi/.node-red/settings.js  
Error: Cannot find module 'i2c-bus'

---

<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:** [28 November 2018 09:33 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/2 "2018-11-28T09:33:39Z")

</div>

You say it is a new installation, but did you already have `/home/pi/.node-red/settings.js` in place with any changes in?

Have a look in that file for any reference to `i2c-bus`.

---

<div class="post-metadata">

**Author:** ![jbreda007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jbreda007/32/6890_2.png) [@jbreda007](https://discourse.nodered.org/u/jbreda007)\
**Post date:** [28 November 2018 09:51 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/3 "2018-11-28T09:51:53Z")

</div>

Thanks for your reply, here is the settings.js file.

/\*\*

- Originale latest version: [https://raw.githubusercontent.com/node-red/node-red/master/settings.js](https://raw.githubusercontent.com/node-red/node-red/master/settings.js)

\*\*/

var fs = require("fs");

var i2c = require("i2c-bus");

var mySettings;

try {

```
mySettings = require("/home/pi/.node-red/redvars.js");

```

} catch(err) {

```
mySettings = {};

```

}

module.exports = {

uiPort: process.env.PORT || 1880,

mqttReconnectTime: 15000,

serialReconnectTime: 15000,

debugMaxLength: 1000,

flowFile: 'flows.json',

flowFilePretty: true,

httpStatic: '/home/pi/.node-red/public',

functionGlobalContext: {

os:require('os'),

moment:require('moment'),

fs:require('fs'),

```
	i2c:require('i2c-bus'),

```

mySettings:mySettings

},

logging: {

console: {

level: "info",

metrics: false,

audit: false

}

},

adminAuth: { type: "credentials", users: [{ username: "", password: "", permissions: "\*" }] },

httpNodeAuth: {user:"admin", pass:""},

editorTheme: { projects: { enabled: false }

}

// By default, credentials are encrypted in storage using a generated key. To

// specify your own secret, set the following property.

// If you want to disable encryption of credentials, set this property to false.

// Note: once you set this property, do not change it - doing so will prevent

// node-red from being able to decrypt your existing credentials and they will be

// lost.

//credentialSecret: "a-secret-key",

//https: {

// key: fs.readFileSync('privatekey.pem'),

// cert: fs.readFileSync('certificate.pem')

//},

//requireHttps: tr

---

<div class="post-metadata">

**Author:** ![jbreda007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jbreda007/32/6890_2.png) [@jbreda007](https://discourse.nodered.org/u/jbreda007)\
**Post date:** [28 November 2018 09:52 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/4 "2018-11-28T09:52:48Z")

</div>

and i did install peter scargills script before testing.

John

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [28 November 2018 10:03 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/5 "2018-11-28T10:03:25Z")

</div>

If you really didn't have a settings.js file before (for example having installed Node-RED on that machine before), then you need to go to Pete Scargill's website and highlight the issue to him, as it would appear he is using a modified settings.js.

Try comparing that file against the "Originale" one.

Personally I would delete everything in the .node-red directory and start again, to confirm that the settings.js file is the from the install rather than an old one.

---

<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:** [28 November 2018 10:05 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/6 "2018-11-28T10:05:17Z")

</div>

Please read this post on sharing code on the forum: [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

You can see at the top of the settings file it has `var i2c = require("i2c-bus");` - which is where it is trying to load the `i2c-bus` module. That is _not_ part of the default settings file.

...

I see @ukmoose has also replied - I echo his comments.

---

<div class="post-metadata">

**Author:** ![jbreda007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jbreda007/32/6890_2.png) [@jbreda007](https://discourse.nodered.org/u/jbreda007)\
**Post date:** [28 November 2018 10:16 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/7 "2018-11-28T10:16:54Z")

</div>

Thanks for your help.

I'm going to start over and see if i can find out where it comes from.

john

---

<div class="post-metadata">

**Author:** ![jbreda007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jbreda007/32/6890_2.png) [@jbreda007](https://discourse.nodered.org/u/jbreda007)\
**Post date:** [28 November 2018 10:19 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/8 "2018-11-28T10:19:47Z")

</div>

ok, thanks - i replied to ukmoose and i am going to start fresh and see where it comes from. Is it possible that installing a node via the palette manager or by npm install can modify settings.js?

john

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [28 November 2018 10:24 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/9 "2018-11-28T10:24:13Z")

</div>

If you are starting again then delete the .node-red folder.  
You said you used Peter Scargills script, which script is that? The recommended way of installing node red on a pi is here  
[https://nodered.org/docs/hardware/raspberrypi](https://nodered.org/docs/hardware/raspberrypi)

---

<div class="post-metadata">

**Author:** ![jbreda007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jbreda007/32/6890_2.png) [@jbreda007](https://discourse.nodered.org/u/jbreda007)\
**Post date:** [28 November 2018 10:40 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/10 "2018-11-28T10:40:52Z")

</div>

Hi Colin,

you can see the script here: [https://tech.scargill.net/the-script/#comment-46288](https://tech.scargill.net/the-script/#comment-46288)

Easy way of installing a bunch of stuff including npm, nodered, sqlite,apache etc etc.

Perhaps that is the problem and i'm going to start with a new rpi stretch installation and see how it goes. I'll use the recommended node-red install procedure and try and install some nodes that I have had problems with before - basically crashed node red and had to start over again. I'll report when i have finished and hopefully tracked down the issue.

John

---

<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:** [28 November 2018 11:42 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/11 "2018-11-28T11:42:48Z")

</div>

> [@jbreda007](#):
>
> Is it possible that installing a node via the palette manager or by npm install can modify settings.js?

No, settings.js is not modified by installing nodes

---

<div class="post-metadata">

**Author:** ![jbreda007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jbreda007/32/6890_2.png) [@jbreda007](https://discourse.nodered.org/u/jbreda007)\
**Post date:** [29 November 2018 10:06 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/12 "2018-11-29T10:06:22Z")

</div>

Thanks for all the help Nick (and others),

I installed node-red and npm as you suggested, and then scargills script afterwards omitting the npm and node-red part of the installation and all worked perfectly.

I know a lot of people are using the scargill script and I'll post this info on his blog also.

Just a quick question, the node-red-node-email node gets installed during the node-red installation as a default. There is a newer version available as the palette manager says there is an update, but it is not updatable from the palette manager as it is installed globally. It has to be uninstalled and reinstalled to work. Little bit of a pain.

Thanks again

John

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [29 November 2018 10:19 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/13 "2018-11-29T10:19:35Z")

</div>

That’s something else to mention to Pete, search the forum for how to fix its come up several times.

---

<div class="post-metadata">

**Author:** ![jbreda007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jbreda007/32/6890_2.png) [@jbreda007](https://discourse.nodered.org/u/jbreda007)\
**Post date:** [29 November 2018 10:32 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/14 "2018-11-29T10:32:34Z")

</div>

I'll do that - thank you.

john

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [29 November 2018 16:01 UTC](https://discourse.nodered.org/t/error-cannot-find-module-i2c-bus/5259/15 "2018-11-29T16:01:38Z")

</div>

Yes. The default email node is in line with the core Node-RED in that it still works on nodejs v4. We will update to the later email node as soon as we drop v4 support in our next release
