Sign in to follow this  
Wazthunder

babel-cli + nodejs + ragemp

Recommended Posts

Hello.
I have problems connect nodejs server to ragemp.

I have error, what express 

Error: E:\Project\Rage_Server\server-files\packages\foundation\server.js:2
import express from "express";
       ^^^^^^^

SyntaxError: Unexpected identifier.

This is all because I can not run babel-cli
If I put in package.json main: npm start ragemp does not see js server

 

how do i run babel?

server.js:

"use strick";
import express from "express";
 
const server = express();
 
server.listen(3000, function () {
console.log("server nodejs is started!");
});

package.json:

{
"name": "GTA_V",
"version": "1.0.0",
"description": "GTA_V 1.0",
"main": "server.js",
"scripts": {
"start": "nodemon --exec babel-node server.js"
},
"author": "Wazthunder",
"license": "ISC",
"dependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-preset-env": "^1.7.0",
"express": "^4.16.4",
"nodemon": "^1.18.10"
}

Share this post


Link to post
Share on other sites
Posted (edited)

Hello, with import some expenses are not in export default so you just have to do

import * as express from 'express';

ou importer le simplement comme ça:

const express = require('express');

 

use your webpack to make babel transpose the code? because dependencies alone are not enough, you must also configure the project.

and also here are the types, very useful for auto-completion. :)

Edited by zoukilama

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.