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

require('mysql2') breaks "npm start" #1965

Closed
h3llyeah opened this issue Apr 20, 2023 · 5 comments · Fixed by #2988
Closed

require('mysql2') breaks "npm start" #1965

h3llyeah opened this issue Apr 20, 2023 · 5 comments · Fixed by #2988

Comments

@h3llyeah
Copy link

If i add to my project
const mysql = require('mysql2');
and launch my nodejs project with npm start

i get error

/nodejs_project/node_modules/lru-cache/dist/cjs/index.js:359
    #initializeTTLTracking() {
                          ^

SyntaxError: Unexpected token '('
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/helar/projects/nodejs/nodejs_udemy/10_sql_intro/node_modules/lru-cache/dist/cjs/index-cjs.js:5:36)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

Setup:
OS: Ubuntu 22.04.1 LTS
Nodejs: v12.22.9
mysql2: mysql2@3.2.3

This problem seems to start from verstion mysql2@3.2.1.
mysql2@3.2.0 is ok.

@sidorares
Copy link
Owner

Are you able to upgrade node version? node v12 is currently one year past its end of life.

@basti1302
Copy link

@sidorares you might want to update https://github.com/sidorares/node-mysql2/blob/master/package.json#L54 to say >= 14 just for consistency.

In the future, it might also be nice to point out dropping support for Node.js versions as a breaking change in the changelog. Of course, one might find it debatable whether such a warning is necessary for EOL versions of Node.js.

@jerrychong25
Copy link

Faced similar error on my end.

In the end, I've upgraded my node version and it works.

@zoobibackups
Copy link

this work fine on the backend , but at cpanel where i have following node version

  • 10.24.1
  • 11.15.0
  • 12.22.9
  • 14.18.3
  • 16.17.0

and i ahve tried mysql2 veriosn 3.2.0, 3.2.1 3.3.0, 3.4.0 , but non of the above is working .

@Sergiussupa
Copy link

Use terminal:


curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
source ~/.bashrc

node -v
nvm install v20.11.0
node -v

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

Successfully merging a pull request may close this issue.

6 participants