Hello, Guest

By registering with us, you'll be able to discuss, share and private message with other members of our community.
What's new

Installing Server node.js Packages for Rage:Mp

Alexalsaud

Administrative
Staff member
Admin
Joined
Aug 5, 2024
Messages
337
ICoins
1,501

Installing Server node.js Packages for Rage:Mp


Very often people ask a question like: "How to install node.js packages for the server?". In this article, I will try to clearly explain how to do this.

1725039734286.png

Click start, open the command line (Win + R, cmd). Go to the folder with the server (in my case, it is C:\RAGE\server-files).
It looks something like this (text from cmd):

Code:
cd C:\RAGE\server-files

Initialize the npm package.json file:

Code:
npm init -y

Install the packages we need (mysql for example):

Code:
npm install mysql

Code:
Next, we can do require in the .js file we are interested in (using the example index.js):

JavaScript:
var mysql      = require('mysql');

var connection = mysql.createConnection({
 host : 'gta5-multiplayer_localhost',
 user : 'gta5-multiplayer_user',
 password : 'gta5-multiplayer_password',
 database : 'gta5-multiplayer_db'
});
 
connection.connect();
 
connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
 if (err) throw err;
 
 console.log('The solution is: ', rows[0].solution);
});
 
connection.end();
 
Back
Top