module.js 340 error Cannot find module 'bonescript'

1.6k views Asked by At

I am getting this error when trying to use 'bonescript'. I have gone through the many solutions discussed on this forum related to this problem but unfortunately I am not getting. I am using Debian OS

The code which I want to run

var b = require('bonescript');
 
b.pinMode('P8_12', b.INPUT);
b.pinMode('P8_13', b.OUTPUT);
 
setInterval(copyInputToOutput, 100);
 
function copyInputToOutput() {
    b.digitalRead('P8_12', writeToOutput);
    function writeToOutput(x) {
        b.digitalWrite('P8_13', x.value);
    }
}

I am getting following error

module.js:340
throw err;
^
Error: Cannot find module 'bonescript'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/ubuntu/workspace/blinky.js:1:71)
etc...

2

There are 2 answers

2
Tim On BEST ANSWER

Did you do npm install bonescript in the project folder? It can't find that module most likely because it's not installed, or if it is installed it may not have the correct permissions for your app to load it.

0
Phil321 On

I had similar problem recently,

I was working through Putty and couldn't run program in home directory, still being able to execute the same program throughout Cloud9 IDE page.

(Working as root to be clear)

For me putting these two commands helped:

export NODE_PATH=/usr/local/lib/node_modules/
export NODE_MODULES_CONTEXTS=1

Since then, I was able to run my program and also check bonescript version:

node -pe "require('bonescript').getPlatform().bonescript"