Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'i2c-bus' even we have npm install i2c-bus #419

Open
vkjuju opened this issue Jul 24, 2018 · 9 comments
Open

Cannot find module 'i2c-bus' even we have npm install i2c-bus #419

vkjuju opened this issue Jul 24, 2018 · 9 comments

Comments

@vkjuju
Copy link

vkjuju commented Jul 24, 2018

We hit a weird error(Error: Cannot find module 'i2c-bus') even we have done npm install i2c-bus, we have also checked:

$npm list|grep i2c-bus
├─┬ [email protected]
│ ├─┬ [email protected]
│ ├── [email protected] deduped

the error is as follows, please kindly be advised:

Error: Cannot find module 'i2c-bus'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object. (/home/pi/Dexter/GrovePi/Software/NodeJS/libs/grovepi.js:2:19)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object. (/home/pi/Dexter/GrovePi/Software/NodeJS/libs/sensors/base/sensor.js:3:20)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
@RobertLucian
Copy link
Contributor

RobertLucian commented Jul 27, 2018

I've just tried the NodeJS library and I haven't had any issues with it. The installation of node-grovepi went fine and that was it. And I already have done it a couple of times so it works.

And it doesn't make any sense for npm to not be able to install i2c-bus since that's already up on npm. Maybe you can uninstall these I2C packages, or better yet all of them and start from scratch again by running the install command.

Just so you know, I've been doing this on my Stretch Raspbian For Robots image dated this summer (the latest one). These following details might also help you: the npm version is 5.6.0, node version is 9.11.2 and this is the package tree I get when I type npm list:

nodejs

The version of node-grovepi shouldn't have to do anything with your issue. On the NPM repo there's the 2.2.2 version and on this repo it's the 2.2.0.

@vkjuju
Copy link
Author

vkjuju commented Jul 27, 2018

please take a look at the following npmlist i2c-bus, does that mean my ic2-bus installed successfully ?

Thanks
Joe

npm list i2c-bus
[email protected] /home/pi/workspace/rapiro-iotf
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
└── [email protected] deduped

@RobertLucian
Copy link
Contributor

So it looks yeah. Was the re-installation that did the job for you? Are you now able to import the module in the console?

@vkjuju
Copy link
Author

vkjuju commented Jul 27, 2018

no luck after reinstall , I don't know how to debug this issue, any more advice ? other modules running perfectly on my pi3 except this one, I have been hanging there for over one week :( any chance for teamviewer ? Thanks

@vkjuju
Copy link
Author

vkjuju commented Jul 28, 2018

my node.js code is as follows, looks like serialport calling j2c-bus module, any advice would be appreciated .

const SerialPort = require('serialport');
const Readline = SerialPort.parsers.Readline;
const port = new SerialPort("/dev/ttys0",{
baudRate: 57600,
parser: new Readline("\n")
});

@vkjuju
Copy link
Author

vkjuju commented Jul 28, 2018

working around it as follows:
cd /home/pi/Dexter/GrovePi/Software/NodeJS/libs/sensors/base
npm install i2c-bus

@vkjuju
Copy link
Author

vkjuju commented Jul 28, 2018

but we hit another error:

pi@raspberrypi:~/workspace/rapiro-iotf $ sudo node robot_main.js
starting
info GrovePi.board GrovePi is initing
/home/pi/workspace/rapiro-iotf/robot_main.js:165
soundSensor = new SoundAnalogSensor(2)
^

TypeError: SoundAnalogSensor is not a constructor
at onInit (/home/pi/workspace/rapiro-iotf/robot_main.js:165:16)
at GrovePi.init (/home/pi/workspace/rapiro-iotf/node_modules/node-grovepi/grovepi.js:73:9)
at start (/home/pi/workspace/rapiro-iotf/robot_main.js:268:9)
at Object. (/home/pi/workspace/rapiro-iotf/robot_main.js:315:1)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)

@vkjuju
Copy link
Author

vkjuju commented Jul 28, 2018

node.js code:
function start() {
console.log('starting')

board = new Board({
debug: true,
onError: function(err) {
console.log('TEST ERROR')
console.log(err)
},
onInit: function(res) {
if (res) {
ultrasonicSensor = new UltrasonicDigitalSensor(2)
lightSensor = new LightAnalogSensor(1)
soundSensor = new SoundAnalogSensor(2)
var buttonSensor = new ButtonDigitalSensor(5)

             buttonSensor.stream(100,function(res){
             if(res==1){
             processing_music.stop();
            trigger=false;
            can_record=true;
            speaker_using=false;
             sp.write("#M00\n");

             }
             }
            );

@vkjuju
Copy link
Author

vkjuju commented Jul 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants