Reputation: 89
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')
this is my code
var date = new Date();
var dateFormat = require('dateFormat');
var periode = dateFormat(date, "yyyy-mm");
Any suggestions?
Upvotes: 2
Views: 6688
Reputation: 314
Run:
npm i dateformat
Using the "F" will give an error: "no such versions available".
Upvotes: 0
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
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