Skip to content

Uncaught ReferenceError: require is not defined #49475

Answered by bycop
Luis-Surec asked this question in General
Discussion options

You must be logged in to vote

Hi, at first, require is not available on browser based javascript. If you're trying to run this code without node script.js, it'll not works.
Then, you should put the require line at the top of your file, not on a function.
Then you can try to use import mysql from 'mysql' if you're in es module configuration

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Luis-Surec
Comment options

Answer selected by RedYetiDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #49474 on September 03, 2023 18:41.