laravel 如何解决“TypeError: process.getuid is not a function”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/56639025/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:20:45  来源:igfitidea点击:

How to solve "TypeError: process.getuid is not a function"

node.jsreactjslaravelnpmwebpack

提问by kelvin

I am running react.js with laravel and watching changes with yarn run watchwhich has worked fine until I began to come across this error with webpack any time I used yarn or npm after I made some windows 10 updates (I really don't know if that could be a reason) - I would love any help.

我正在使用 laravel 运行 react.js 并观察运行良好的更改,yarn run watch直到我在进行一些 Windows 10 更新后使用 yarn 或 npm 时开始遇到 webpack 错误(我真的不知道这是否可以)成为一个原因) - 我很乐意提供任何帮助。

if (!e && fileOwnerId === process.getuid()) utimesSync(openCollectivePath, now, now)

The error:

错误:

TypeError: process.getuid is not a function at C:\project_path\node_modules\webpack-cli\bin\cli.js:352:43 at FSReqCallback.oncomplete (fs.js:153:23)

采纳答案by Yumecosmos

Was it by chance Monday when this happened? If so, I believe it's related to this issue: https://github.com/webpack/webpack-cli/issues/962

发生这种情况是周一偶然吗?如果是这样,我相信它与这个问题有关:https: //github.com/webpack/webpack-cli/issues/962

From what I gather Webpack CLI which Laravel Mix uses tries to print a message once every six days asking the user to consider donating, but recent versions relied on a function that isn't available in Windows. The logic was originally added as a consideration for people who were bothered by constantly seeing the message, and later tweaked to avoid file permission issues for Mac and Linux users, but the latter change caused problems for Windows users only on Mondays.

从我收集到的 Laravel Mix 使用的 Webpack CLI 尝试每六天打印一次消息,要求用户考虑捐赠,但最近的版本依赖于 Windows 中不可用的功能。该逻辑最初是作为对不断看到消息而烦恼的人的考虑而添加的,后来进行了调整以避免 Mac 和 Linux 用户的文件权限问题,但后者的更改仅在星期一对 Windows 用户造成问题。

A solution proposedby the user rseeburg in that thread was simply to wrap the offending code in a try/catch. However, it looks like the donation message has been removedas of Webpack CLI 3.3.5, so updating the package should fix it. I got it working again by adding "webpack-cli": "^3.3.5"to package.json followed by yarn install.

用户 rseeburg 在该线程中提出解决方案只是将违规代码包装在 try/catch 中。但是,看起来捐赠消息已从Webpack CLI 3.3.5 中删除,因此更新包应该可以修复它。我通过添加"webpack-cli": "^3.3.5"到 package.json 后跟yarn install.

回答by SvEnjoyPro

I was just having this issue as well. I'm not sure what caused it, but deleting my node_modules folder and re-running "npm install" fixed it for me.

我也刚遇到这个问题。我不确定是什么原因造成的,但是删除了我的 node_modules 文件夹并重新运行“npm install”为我修复了它。

回答by Adam

You can do 3 things to fix that :

你可以做 3 件事来解决这个问题:

1- by change you day to any day excepted Monday Because this function if

1- 通过将您一天更改为星期一除外的任何一天 因为此功能如果

 const now = new Date();
if (now.getDay() === MONDAY) {
    const { access, constants, statSync, utimesSync } = require("fs");
    const lastPrint = statSync(openCollectivePath).atime;
    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
        access(openCollectivePath, constants.W_OK, e => {
            if (!e) utimesSync(openCollectivePath, now, now);
        });
    }
}

and that about donating to their package

还有关于捐赠给他们的包裹

2- remove that condition fileOwnerId === process.getuid()), but it's Not Working for windows users so you can the last thing

2- 删除该条件fileOwnerId === process.getuid()),但它不适用于 Windows 用户,因此您可以做最后一件事

3- add this "webpack-cli": "^3.3.5"to your package.jsonin dependencies and run npmthat working for me.

3- 将此添加 "webpack-cli": "^3.3.5"到您package.json的依赖项中并运行npm它对我有用。

回答by alvinMemphis

simply running npm installsolved it for me. didn't have to delete any folders

简单地运行npm install为我解决了它。不必删除任何文件夹