basir / node-react-ecommerce

Build ECommerce Website Like Amazon By React & Node & MongoDB
https://node-react-ecommerce-app.herokuapp.com/
1.69k stars 794 forks source link

Node backend start error #61

Closed RuiLopes98 closed 4 years ago

RuiLopes98 commented 4 years ago

Hey there again!

I'm getting this error: error_cmd~

When trying to execute: node backend/server.js.

This is my server.js code:

import express from 'express';
import data from './data';

const app = express();

app.get("/api/products", (req, res) => {
    res.send(data.products);
});

app.listen(5000, () => {
    console.log("server started at at http://localhost:5000");
});

If someone can help and need extra code or information, please tell me and i'll provide it as fast as possible!

Thanks for the attention!!

basir commented 4 years ago

You did not set babel correctly to transpile ES6 code to ES5. Follow this: https://gist.github.com/basir/d121df24c47861e13a1cdcbed1cca902#cannot-use-import-statement-outside-of-a-module