0

I am using dateformat npm package of version 4.5.1 and getting error on server restart as

server must be sue import to load ES module
usr/src/app/nodemodules/dateformat/lib/dateformat.js | require() ES module is not supported
Shree
  • 145
  • 4
  • 15

2 Answers2

4

I got the same error while using the dateformat package. Then tried a different version which is dateformat@4.6.3 and it worked!

Run the following command in the terminal:

npm i dateformat@4.6.3

Example code:

var dateFormat = require('dateformat');
var now = new Date();
dateFormat(now, "dddd, mmmm dS, yyyy, h:MM:ss TT");
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
0

I think the problem is with your package.json file. You need to import statement instead of require. Or else try this Here

Sibtain Wani
  • 89
  • 1
  • 9
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/30649304) – Tyler2P Dec 23 '21 at 16:18