How To Use An ES6 Import In Node.js

To handle this issue, we use ES6 import

By changing content of package.json file

//package.json

{
    "name": "index",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "type": "module",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "dependencies": {
        "express": "^4.17.1"
    }

now you can import file like in ES6