Hello all!
I am trying to work on a basic script in JavaScript but I have run into a pretty inconvenient error. In my client.js I am trying to require my config (pretty basic JS stuff). But I am met with ReferenceError: require is not defined
My Code:
client.js:
const config = require('./config.js')
fxmanifest.lua:
client_scripts {
'client/*.js',
'config.js',
}
I am also getting another error when the script starts, ReferenceError: module is not defined tracing back to my config.js file
Here is the code for that:
module.exports = {
menu: {
use_menu: true,
open_menu_button: 305,
},
}
Once again pretty basic stuff. If you know any fix please lmk. I have already seen this topic and its really been no help so far.
Thanks in advance! <3
As said above, the client does not have access to require or import, you’ll need to bundle your code if you want to include libraries. For a config file like this you would be better off using a JSON file and importing it with LoadResourceFile or alternatively using convars.