I am looking at a NodeJS project, which is downloaded from GitHub. It has a main file, server.js
, which uses the ES6 module import syntax like this:
import express from 'express';
import bodyParser from 'body-parser';
import fs from 'fs';
import { search } from './lib/words';
I have NodeJS version 4.6.0 installed, which is pretty old, and I do not think it supports this syntax. Instead, it should be like:
var express = require(express)
var bodyParser = require('body-parser')
...
However I can run this project correctly without error, which I think shows that NodeJS supports this syntax, but the NodeJS documentation never specifies such module syntax. What is the reason we can use it here? Thank you for help.