Shree
Shree

Reputation: 165

dateformat npm package giving error on node server restart

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

Upvotes: 0

Views: 1959

Answers (2)

Jiso Chacko
Jiso Chacko

Reputation: 91

I got the same error while using the dateformat package. Then tried a different version which is [email protected] and it worked!

Run the following command in the terminal:

npm i [email protected]

Example code:

var dateFormat = require('dateformat');
var now = new Date();
dateFormat(now, "dddd, mmmm dS, yyyy, h:MM:ss TT");

Upvotes: 7

Sibtain Wani
Sibtain Wani

Reputation: 89

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

Upvotes: 0

Related Questions