Not able to test node.js first demo program. Run throws error

Not able to test node.js first demo program. Run throws error

I am getting below error when I have executed the first demo program:

Bonescript: initialized

Exception: TypeError: require is not a function

Bonescript: initialized

How to solve this?

Thanks

Where are you getting the example from?

Also, can you post the code you are using?

Cheers,

Jon

bone script.png

bone script.png

Sorry, I can’t get that site to connect to my BBAI so I can not check to see if it works on my end.
Perhaps someone else will chime in.

Cheers

Please don't post screen IMAGES... Select the TEXT, copy, and then
paste it in a message.

  A screen image is useless for people using text-to-speech engines or
text-only news clients (note: I read this via gmane's news server, not as
email), and also useless for responders who would comment on specific
lines.

  For me to be able to read a screen image, I have /save/ the file to my
computer, then open it using some graphics editor, and finally delete the
file to avoid cluttering up my system with spurious junk.

  Having said all that...

  If I try to navigate to that apparent path (starting from the "getting
started" page, I end up on beaglebone.org web server, with some option
apparently to provide the route to my beagle.

  https://beagleboard.org/Support/BoneScript/demo_blinkled/

  Problem #1: My BBB is connected to my NAT router/firewall. Providing my
BBB internal LAN private IP is not going to result in a connection:
192.168.1.69

"""
Exception: Please perform setTargetAddress on a valid target
"""

  Try connecting to Cloud9 http://beaglebone.local:3000/ide.html (if that
doesn't work -- ie; you only have a USB connection -- replace
beaglebone.local with the IP number of the USB connection 192.168.7.2
[Windows: use .6. rather than .7. for Mac]).

  Navigate down to cloud9/BeagleBone/pru; (double-) click blinkLED.js to
open the editor window.
"""
#!/usr/bin/env node
////////////////////////////////////////
// blinkLED.js
// Blinks the USR LEDs and P9_14.
// Wiring: P9_14 connects to the plus lead of an LED. The negative lead
of the
// LED goes to a 220 Ohm resistor. The other lead of the resistor
goes
// to ground.
// Setup:
// See:
////////////////////////////////////////
const b = require('bonescript');

const leds = ["USR0", "USR1", "USR2", "USR3", "P9_14"];

for(var i in leds) {
    b.pinMode(leds[i], b.OUTPUT);
}

var state = b.HIGH;
for(var i in leds) {
    b.digitalWrite(leds[i], state);
}

setInterval(toggle, 250);

function toggle() {
    if(state == b.LOW)
        state = b.HIGH;
    else
        state = b.LOW;
    for(var i in leds) {
        b.digitalWrite(leds[i], state);
    }
}
"""
(see how friendlier cut/paste of the /text/ is)

Click >Run
(Ignore debugger warnings -- the Beagle should be flashing all four
on-board LEDs).

Perhaps when posting code it would be best to use the Highlight Code Syntax in Google. Not sure what formatting is used in the email but looks like from a README.

For me, I just went to the site that is in the images that Jennifer provided. The code could be pulled from there.

However, I believe the issue is with the BeagleBoard site and not with the Cloud9 IDE on the board but could be related.

Jon

I read and post using Forte Agent, accessing the "forum" via gmane's
NNTP server as
Newsgroups: gmane.comp.hardware.beagleboard.user (though due to some
glitch, the reply via gmane fails to post on the end host, so I have to
remember to reply-to-email -- I only have that problem with this forum; the
other nine that I handle via gmane post properly)

  The """ is a convention I use (from Python; my alternative marker is
-=-=-) to isolate cut&paste items from console windows. The code is
directly from the cloud9 editor of that demo file.

  There is no option for colorizing text in my news clients

I connected a BBBlack to my Ubuntu Box via USB and I still can not get the BeagleBoard.org page to connect to it. I even tried it to a Windows 10 system and still no go.
I’ve updated the Cloud9 code so I am not sure what the issue is.

I looked at the Chromium debug output and this is what I see:

Uncaught SyntaxError: Unexpected token '<'
bonescript.js:16 GET http://192.168.7.2/bonescript.js net::ERR_ABORTED 404 (Not Found)

However, my BBBlack gets connected at the following link, which looks like a mirror of the beagleboard.org.
http://va3wdg.gw.ircddb.net/bone101/Support/BoneScript/

I can run the scripts from the site but I don’t feel comfortable with the funky URL but I at least know it is not the BBBlack nor my PC connection.

Perhaps there is an issue with the BeagleBoard.org Learn site?

Cheers,

Jon