Javascript ES6 Import

const express=require(‘express’) is the es5 way to import the express module
import express from ‘express’ is the es6 way to import the express module.
But when i try to use the es6 option i get this error
"import express, { urlencoded } from “express”;
^^^^^^

SyntaxError: Cannot use import statement outside a module"
why? and how do i overcome this ?
Please someone guide me on this.

Are you trying to use import in node.js without setting up some sort of es5 to es6 compiler like babel?

yes i trying to use import in node.js just dont know what to setup or how tried babel but seemed a bit complicated to set up so was looking for an alternative

You’re trying to execute use it as an ES6 module, but node.js currently understands CommonJS.