webpackでエラーメッセージ
休み明けの月曜日いつものようにsassやjsをビルドしていたら↓のようなメッセージが表示された。
Thanks for using webpack!
Please consider donating to our Open Collective
to help us maintain this package.
Donate: https://opencollective.com/webpack/donate
C:\***\node_modules\webpack-cli\bin\cli.js:356
if (!e && fileOwnerId === process.getuid()) utimesSync(openCollectivePath, now, now);
^
TypeError: process.getuid is not a function
at e (C:\***\node_modules\webpack-cli\bin\cli.js:356:43)
at FSReqWrap.args [as oncomplete] (fs.js:140:20)
ビルドはされているっぽいので働いてはいるらしい。タイトルは盛りました。
https://nodejs.org/api/process.html#process_process_getuid
によると、どうやらgetuid()
という関数はWindowsやAndroid環境では利用できないとのこと。
私のPCはWindows10なので動かないのは当たり前。
先週まで動いてましたけどね!!
webpackのファイルを確認する
件のコードを確認する。
\node_modules\webpack-cli\bin\cli.js
/**
* Show a hint to donate to our Opencollective
* once a week, only on Monday
*/
const openCollectivePath = __dirname + "/opencollective.js";
const MONDAY = 1;
const SIX_DAYS = 518400000;
const now = new Date();
if (now.getDay() === MONDAY) {
const { access, constants, statSync, utimesSync } = require("fs");
const stat = statSync(openCollectivePath);
const lastPrint = stat.atime;
const fileOwnerId = stat.uid;
const lastPrintTS = new Date(lastPrint).getTime();
const timeSinceLastPrint = now.getTime() - lastPrintTS;
if (timeSinceLastPrint > SIX_DAYS) {
require(openCollectivePath);
// On windows we need to manually update the atime
// Updating utime requires process owner is as same as file owner
access(openCollectivePath, constants.W_OK, e => {
if (!e && fileOwnerId === process.getuid()) utimesSync(openCollectivePath, now, now);
});
}
}
コメントによれば毎週月曜日になると寄付を促す(?)メッセージを表示するもの。
私は使用していたwebpackのバージョンは3.3.3
アップデートしたのは2週間ほど前。
そういえば先週の月曜日はwebpack起動しなかったか・・・。
解決策
https://github.com/webpack/webpack-cli/pull/966
2019/6/24現在のバージョンではこのコードは削除されているので、最新版にアップデートすればすべて解決。
npm i webpack-cli@3.3.5
休み明けからwebpackのエラーの対応はしんどい。