Uncaught ReferenceError: require is not defined #49475
-
VersionNode.js v19.3.0 Platformwindows Subsystemrequire What steps will reproduce the bug?Uncaught ReferenceError: require is not defined function verpass(){ How often does it reproduce? Is there a required condition?En el navegador me aparece que no esta definido What is the expected behavior? Why is that the expected behavior?-- What do you see instead?-- Additional information-- |
Beta Was this translation helpful? Give feedback.
Answered by
bycop
Sep 6, 2023
Replies: 1 comment 1 reply
-
Hi, at first, require is not available on browser based javascript. If you're trying to run this code without |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
avivkeller
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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