Lely Suju
Lely Suju

Reputation: 89

Cannot find module 'date Format'

I have a project using nodejs. I want to format the date using dateformat. when I try on local it works, but when I upload it to the server, dateformat is unreadable (cannot find module 'date format')

enter image description here

this is my code

var date = new Date();
    var dateFormat = require('dateFormat');
    var periode = dateFormat(date, "yyyy-mm");

Any suggestions?

Upvotes: 2

Views: 6688

Answers (3)

Yannick Mussche
Yannick Mussche

Reputation: 314

Run:

npm i dateformat

Using the "F" will give an error: "no such versions available".

Upvotes: 0

Monu
Monu

Reputation: 27

npm install dateFormat getting error npm install dateFormat npm ERR! code ENOVERSIONS npm ERR! No valid versions available for dateFormat

npm ERR! A complete log of this run can be found in: npm ERR! /home/yourprojectname/.npm/_logs/2022-06-08T12_02_03_215Z-debug.log

var date = new Date();
    var dateFormat = require('dateformat');
    var periode = dateformat(date, "yyyy-mm");
install 
npm install dateformat

Upvotes: 0

user3937422
user3937422

Reputation:

I guess you haven't added the module to the project, you can go to the project directory and run the below command or add this module globally

> npm install dateFormat

Upvotes: 8

Related Questions