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

bot.js doesn't run #8

Open
rcsheets opened this issue Dec 31, 2017 · 8 comments
Open

bot.js doesn't run #8

rcsheets opened this issue Dec 31, 2017 · 8 comments

Comments

@rcsheets
Copy link
Member

Instead of the bot running, this happens:

rcsheets@stinger:~/sudobot$ node bot.js

/home/rcsheets/sudobot/node_modules/irc/node_modules/irc-colors/lib/irc-colors.js:3
const colors = {
^^^^^
SyntaxError: Use of const in strict mode.
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/rcsheets/sudobot/node_modules/irc/lib/parse_message.js:1:79)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

This appears to be due to the version of irc-colors which is currently being pulled in by npm install when it resolves the dependencies of irc. We require "irc": "^0.3.12" which requires "irc-colors": "^1.1.0". which ends up being resolved to irc 1.4.1. The bot running in production right now has irc-colors version 1.2.0.

I don't know enough about node to really understand why this is happening, since irc-colors 1.4.1 has the following in its package.json:

"engines": {
  "node": ">=4"
},

I assume this means that irc-colors 1.4.1 is only expected to work on node versions 4 and later. Since we're using 0.10.37, it seems like an error that this version of the package is being selected.

@rcsheets
Copy link
Member Author

rcsheets commented Dec 31, 2017

Googling for SyntaxError: Use of const in strict mode reveals a StackOverflow answer which suggests invoking the script as follows:

node --harmony bot.js

This seems to work around one SyntaxError but reveals a different one:

rcsheets@stinger:~/sudobot$ node --harmony bot.js

/home/rcsheets/sudobot/node_modules/irc/node_modules/irc-colors/lib/irc-colors.js:30
Object.keys(styles).forEach((key) => {
                                   ^
SyntaxError: Unexpected token >
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/rcsheets/sudobot/node_modules/irc/lib/parse_message.js:1:79)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

I assume this syntax is unsupported by node 0.10.37, but I haven't confirmed that.

@hackergrrl
Copy link

hackergrrl commented Dec 31, 2017

It looks like arrow functions came with NodeJS 4.0.0, which supports what you found in irc-colors.

@hackergrrl
Copy link

I upgraded all of the dependencies on my dev machine and it seems to run okay with Node 6.9.5 (and I presume later). I could poke at getting this running on prod?

@rcsheets
Copy link
Member Author

@noffle I had trouble running the bot using v8.9.3 (which is what nvm install --lts installed for me), but it seems my main problem may be with poor error handling as my dev environment doesn't have a serial port. I'm certainly fine with upgrading to a newer node version as long as we don't accidentally break any bot functionality.

@rcsheets
Copy link
Member Author

And if handling a missing serial port really is causing my problem running on 8.9.3, then that should be tracked as a totally separate bug.

@hackergrrl
Copy link

hackergrrl commented Dec 31, 2017

What was the trouble you hit? I ended up upgrading to the latest serialport locally, which still resulted in an error (since I have no serial port device on this machine), but it was no more than a "no serial port found" error. I'd feel best playing with this on the actual machine in question before pushing anything! What box does sudobot run on? I'm very new to the sudo infra setup!

@rcsheets
Copy link
Member Author

rcsheets commented Jan 1, 2018

Serial support has now been removed (see #9). The bot runs on a system called space. I'll give you more info on getting access over IRC.

@rcsheets
Copy link
Member Author

rcsheets commented Jan 1, 2018

Removing serial support and updating to node 8.9.3 fixes this problem for me.

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

No branches or pull requests

2 participants