电子包装器产生 ENOENT

electron-packager spawn ENOENT(电子包装器产生 ENOENT)
本文介绍了电子包装器产生 ENOENT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个通过 gui 控制 gulp 任务的电子应用程序.您单击一个任务,它就会运行.很简单的东西.在 macOS 上,当我运行 npm start 时,它运行得很好,但是当我用电子打包器打包它时,我得到了这个错误:

I'm working on an electron app that controls gulp tasks via gui. You click on a task and it runs. Pretty simple stuff. On macOS, when I run npm start it runs just fine, but when I package it with electron-packager, I get this error:

Uncaught Exception:
Error: spawn gulp ENOENT
    at exports._errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

这是代码:

exports.runTask = (taskName, projPath) => {
    const cp = spawn('gulp', [ taskName ], {cwd: projPath});
    cp.stdout.setEncoding('utf8');
    cp.stdout.on('data', data => {
        console.log(data);
        mainWindow.webContents.send('task-console-data', data);
    });

    cp.stderr.setEncoding('utf8');
    cp.stderr.on('data', data => {
        console.error(data);
        displayNotification({text: `[error] ${data}`});
        mainWindow.webContents.send('task-console-data', `[error] ${data}`);
    });

    cp.on('exit', code => {
        if (code === 0) {
          displayNotification({
            title: 'gulp',
            subtitle: 'Finished running tasks'
          });
        } else if ( !code || code === null ) {
            return;
        } else {
            console.error(`Exited with error code ${code}`);

            displayNotification({
                title: 'gulp',
                subtitle: `Exited with error code ${code}`,
                sound: 'Basso'
            });
        }
    });
};

推荐答案

如果其他人遇到这个问题,答案是更正 $PATH.npm 上有一个包可以为你做这件事.

In case anyone else is running into this problem, the answer is to correct the $PATH. There is a package on npm that does this for you.

https://www.npmjs.com/package/fix-path

这篇关于电子包装器产生 ENOENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Update another component when Formik form changes(当Formik表单更改时更新另一个组件)
Formik validation isSubmitting / isValidating not getting set to true(Formik验证正在提交/isValiating未设置为True)
React Validation Max Range Using Formik(使用Formik的Reaction验证最大范围)
Validation using Yup to check string or number length(使用YUP检查字符串或数字长度的验证)
Updating initialValues prop on Formik Form does not update input value(更新Formik表单上的初始值属性不会更新输入值)
password validation with yup and formik(使用YUP和Formick进行密码验证)