3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Node.jsのCron実行で`NodeMoment Timezone has no data for Japan/Tokyo.`

Posted at

Node.jsで定期実行する際にcronパッケージを使うことがあります。

$ npm i cron
app.js
'use strict'

const CronJob = require('cron').CronJob;

new CronJob('*/1 * * * * *', () => {
	//処理
}, null, true, 'Japan/Tokyo');

実行すると

Moment Timezone has no data for Japan/Tokyo. See http://momentjs.com/timezone/docs/#/data-loading/.

と警告がでました。

app.js
'use strict'

const CronJob = require('cron').CronJob;

new CronJob('*/1 * * * * *', () => {
	//処理
}, null, true, 'Asia/Tokyo');

こうすると治ります。

どこかの記述でJapan/Tokyoって見た気がしたんだけど...苦笑

3
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?