Search code examples
mysqlnode.jssyntax-errorunexpected-token

the actual mysql package appears to have a syntax error when used with node.js


So i'm trying to use mysql with nodejs, and when I attempt to use it, I receive a syntax error that appears to originate within the MySQL package itself.

require('/usr/local/bin/mysql')

which returns the exception:

/usr/local/Cellar/mysql/8.0.26/bin/mysql:1
����

SyntaxError: Invalid or unexpected token

Does anyone know why this might be happening?


Solution

  • Thanks for the comments, guys. The solution was that I just had to install the latest version of the MySQL module from Github.

    npm install mysqljs/mysql
    

    forgot to add: I changed require('/usr/local/bin/mysql') back to require('mysql') after installing the latest version of MySQL as well.