I managed to run it successfully by using require as shown below:

const fns = require('date-fns')

console.log(fns.format(new Date(), "'Today is a' eeee"))

Update:

I installed node v16.6.1 following the instructions in this answer and now I can run the following code successfully:

import { format } from 'date-fns';

console.log(format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSS"));
Answer from Arvind Kumar Avinash on Stack Overflow
๐ŸŒ
date-fns
date-fns.org
date-fns - modern JavaScript date utility library
date-fns provides the most comprehensive yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
๐ŸŒ
npm
npmjs.com โ€บ package โ€บ date-fns
date-fns - npm
Modern JavaScript date utility library. Latest version: 4.1.0, last published: a year ago. Start using date-fns in your project by running `npm i date-fns`. There are 24815 other projects in the npm registry using date-fns.
      ยป npm install date-fns
    
Published ย  Sep 17, 2024
Version ย  4.1.0
๐ŸŒ
Envato Tuts+
code.tutsplus.com โ€บ home โ€บ javascript
Using date-fns for Easy Date Manipulation | Envato Tuts+
July 28, 2023 - One of the primary tasks when working ... formatting dates, but it lacks support for custom formats. date-fns provides the format function for this purpose....
๐ŸŒ
Time and Date
timeanddate.com
timeanddate.com
Welcome to the world's top site for time, time zones, and astronomy. Organize your life with free online info and tools you can rely on. No sign-up needed.
Find elsewhere
๐ŸŒ
DevDocs
devdocs.io โ€บ date_fns
DevDocs โ€” date-fns documentation
date-fns 2.29.2 API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more.
๐ŸŒ
SourceForge
sourceforge.net โ€บ projects โ€บ date-fns.mirror
date-fns download | SourceForge.net
Modern JavaScript date utility library. date-fns is a modern JavaScript date utility library that offers the most comprehensive toolset for manipulating JavaScript dates in a browser and Node.js.
๐ŸŒ
GitHub
github.com โ€บ date-fns โ€บ date-fns
GitHub - date-fns/date-fns: โณ Modern JavaScript date utility library โŒ›๏ธ
date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js
Author ย  date-fns
๐ŸŒ
Date-fns
blog.date-fns.org โ€บ v40-with-time-zone-support
v4.0 is out with first-class time zones support!
September 16, 2024 - In 2022, I came up with @date-fns/utc that immediately felt right. You get an option to make all the calculations in UTC and remove the local time zone from the equation without adding any extra weight to the core library.
๐ŸŒ
JSFiddle
jsfiddle.net โ€บ tmtron โ€บ 31rbesxp
datefns - JSFiddle - Code Playground
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
๐ŸŒ
JavaScript in Plain English
javascript.plainenglish.io โ€บ date-manipulation-in-js-made-easy-with-date-fns-6c66706a5874
Date manipulation in JS made easy with date-fns | by Unpackaged Reviews | JavaScript in Plain English
July 28, 2020 - Date manipulation in JS made easy with date-fns Overview Ever written a method to get the time of day in GMT? or have wondered if I need to convert the time to UTC? Most applications have some common โ€ฆ
๐ŸŒ
Fulcrumapp
help.fulcrumapp.com โ€บ en โ€บ articles โ€บ 4037876-date-manipulation-with-date-fns
Date Manipulation with date-fns | Fulcrum Help Center
date-fns is a date utility library that provides a comprehensive toolset for manipulating JavaScript dates in a browser & Node.js.
๐ŸŒ
StaticMania
staticmania.com โ€บ blog โ€บ javascript-date-time-library
Working with JavaScript Date and Time Libraries: Moment.js and Date-fns - StaticMania
Both Moment.js and Date-fns are powerful libraries for handling date and time operations in JavaScript. However, with Moment.js being deprecated and Date-fns offering a lightweight, modular, and immutable approach, Date-fns is the preferred choice for new projects.
๐ŸŒ
DEV Community
dev.to โ€บ dmtrkovalenko โ€บ you-might-not-need-date-fns-23f7
You might not need date-fns - DEV Community
May 10, 2021 - As you can see date-fns takes 13.88kb gzip when only importing the most important functionality. It is a lot. Here is a pretty fun example of a react datepicker that has a peer dependency on date-fns. Date-fns takes 3 times more space than the datepicker itself and mostly 1/3 size of react.
๐ŸŒ
Lloyd Atkinson
lloydatkinson.net โ€บ projects โ€บ 2023 โ€บ date-fns-additional
Useful Date Time Functions - Lloyd Atkinson
January 17, 2023 - date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
๐ŸŒ
Javascript-conference
javascript-conference.com โ€บ home โ€บ why you should use date-fns for manipulating dates with javascript
Why you should use date-fns for manipulating dates with JavaScript - International JavaScript Conference
July 22, 2024 - The first and one of the most important differences is already in the name of the project, since fns stands for functions. date-fns is a collection of functions that allow you to work with date values.