I am looking at a NodeJS project that is downloading from GitHub . It has a main file server.jsthat uses the ES6 module import syntax as follows:
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 don't think it supports this syntax. Instead, it should look like this:
var express = require(express)
var bodyParser = require('body-parser')
...
However, I can start this project correctly without errors, which, I think, shows that NodeJS supports this syntax, but the NodeJS documentation never indicates such a module syntax. What is the reason that we can use it here? Thank you for your help.
source
share