Nodejs 错误:生成 ENOENT

2024-04-14

我是nodejs的新手,我正在尝试运行它:

我得到:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)

我该如何解决?


问题可能出在这段代码中:

/**

 */
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define, require, module, process */

var childprocess = require("child_process"),
    util = require("util"),
    fs = require("fs");
var procWrapper = require("./processwrapper");
var spawn = childprocess.spawn;
module.exports = function () {
    "use strict";
    var pvs = procWrapper();
    var o                                   = {},
        output                              = [],
        readyString                         = "<PVSio>",
        wordsIgnored                        = ["", "==>", readyString],
        restarting                          = false,
        sourceCode,
        filename,
        processReady                        = false,
        pvsio,
        workspaceDir                        = process.cwd() + "/public/";
    /**
     * get or set the workspace dir. this is the base directory of the pvs source code
     * @param {String} dir
     * @return {String} the current workspace directory
     */
    o.workspaceDir = function (dir) {
        if (dir) {util.log("OK");

            dir = dir.substr(-1) !== "/" ? (dir + "/") : dir;
            workspaceDir = dir;
    util.log("OOO");
            return o;
        }
util.log("IIII");
        return workspaceDir;
    };

    /**
     * starts the pvs process with the given sourcefile 
     * @param {String} filename source file to load with pvsio
     * @param {function({type:string, data:array})} callback function to call when any data is received  in the stdout
     * @param {function} callback to call when processis ready
     */
    o.start = function (file, callback, processReadyCallback) {
        filename = o.workspaceDir() + file;
        function onDataReceived(data) {
            var lines = data.split("\n").map(function (d) {
                return d.trim();
            });
            var lastLine = lines[lines.length - 1];
            //copy lines into the output list ignoring the exit string, the startoutput string '==>'
            //and any blank lines
            output = output.concat(lines.filter(function (d) {
                return wordsIgnored.indexOf(d) < 0;
            }));

            if (processReady && lastLine.indexOf(readyString) > -1) {
                var outString = output.join("").replace(/,/g, ", ").replace(/\s+\:\=/g, ":=").replace(/\:\=\s+/g, ":=");
                //This is a hack to remove garbage collection messages from the output string before we send to the client
                var croppedString = outString.substring(0, outString.indexOf("(#"));
                outString = outString.substring(outString.indexOf("(#"));
                util.log(outString);
                callback({type: "pvsoutput", data: [outString]});
                //clear the output
                output  = [];
            } else if (lastLine.indexOf(readyString) > -1) {
                //last line of the output is the ready string
                processReadyCallback({type: "processReady", data: output});
                processReady = true;
                output = [];
            }
        }

        function onProcessExited(code) {
            processReady = false;
            var msg = "pvsio process exited with code " + code;
            util.log(msg);
            callback({type: "processExited", data: msg, code: code});
        }

        pvs.start({processName: "pvsio", args: [filename],
            onDataReceived: onDataReceived,
            onProcessExited: onProcessExited});

        util.log("pvsio process started with file " + filename + "; process working directory is :" + o.workspaceDir());
util.log("OK");

        return o;
    };

    /**
     * sends a command to the pvsio process. This method returns immediately. The result of the command
     * will be by the 'on data' event of the process standard output stream
     * @param {string} command the command to send to pvsio
     */
    o.sendCommand = function (command) {
        util.log("sending command " + command + " to process");
        pvs.sendCommand(command);
        return o;
    };

    /**
     * gets the source code pvs io is executing
     * @param {string} path the path the to file whose content is to be fetched
     * @param {function({type:string, data, message:string})} callback callback to execute when sourcecode has been loaded
     * @returns {this}
     */
    o.readFile = function (path, callback) {
        pvs.readFile(path, callback);
        return o;
    };

    /**
     * writes  the file passed to the disk
     * @param {fileName:string, fileContent: string} data Object representing the sourcecode to save
     * @param {function ({type: string, data: {fileName: string}})} callback function to invoke when the file has been saved
     */
    o.writeFile = function (path, data, callback) {
        pvs.writeFile(path, data, callback);
        return o;
    };


    /**
     * closes the pvsio process
     * @param {string} signal The signal to send to the kill process. Default is 'SIGTERM'
     */
    o.close = function (signal) {
        signal = signal || 'SIGTERM';
        pvs.kill(signal);
        return o;
    };
    return o;
};

启动后,我转到 localhost:8082,它崩溃了! 就这样。 抱歉,提供这些小信息可能无法帮助我。


在我的 Windows 7 机器上更新了很多程序后,我遇到了同样的错误。幸运的是,我记得我删除了 git 并使用更新的版本和不同的安装选项再次安装了它。不同之处在于选择“调整 PATH 环境”设置中的第三个选项(“从 Windows 命令提示符中使用 Git 和可选的 Unix 工具”)。

将node.js更新到较新的版本(实际上是0.10.31)后问题仍然存在。所以我决定再次删除 git,瞧,套接字服务器又开始工作了。现在我将使用默认选项再次安装 git,这不会修改 PATH 环境变量。

所以问题来自于可通过 PATH 变量访问的 unix 工具,例如由 MinGW、Git 或 Cygwin 安装的工具(可能 - 未测试)。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Nodejs 错误:生成 ENOENT 的相关文章

随机推荐

  • Python - 检查用户是否具有管理员权限

    我正在用 Python 3 x 编写一个小程序作为自学项目 我的想法是让程序允许用户输入两个文本字段 然后将用户的输入插入到两个特定注册表项的值中 有没有一种简单的方法来检查当前用户是否可以访问注册表 我宁愿它清楚地告诉用户他 她需要管理员
  • 快速选择所有带有css背景图片的元素

    我想抓取页面上具有 css 背景图像的所有元素 我可以通过过滤函数来做到这一点 但在包含许多元素的页面上速度非常慢 filter function return this css background image addClass bg f
  • 在python 2.7中使用for循环创建多个数据帧

    我有一个位置列表 HOME Office SHOPPING 和一个 pandas 数据框 DF Start Location End Location Date OFFICE HOME 3 Apr 15 OFFICE HOME 3 Apr
  • iOS 获取代理设置

    在我的项目中 我使用 libcurl 通过互联网下载数据 问题是 libcurl 无法检测 wifi 连接的代理设置 我必须手动设置 libcurl 的设置 所以我想知道如何获取 wifi 连接的代理设置 我在钥匙串中找到了一些有关信息的线
  • 邮件程序错误缺少模板

    Hello 我有问题行动邮递员 当我尝试执行操作时 rake send email 我收到一个错误 rake aborted ActionView MissingTemplate Missing template user mailer m
  • 使用 PHP 从 S3 获取视频并上传到 YouTube

    我有一些代码可以将视频文件上传到 YouTube yt new Zend Gdata YouTube httpClient create a new VideoEntry object myVideoEntry new Zend Gdata
  • 在增强for循环中使用final for循环变量的目的是什么?

    我理解下面的声明是如何工作的 for final Animal animal animalList do some function 但是这里使用final关键字的目的是什么 这样做有两个可能的原因 它可能只是避免在循环体中意外更改循环变量
  • 对象创建定义属性设置器

    我需要做到这一点 以便每次更改对象上的特定属性时 它都会调用同一对象上的特殊方法 Example MyObject prototype Object create specialMethod function someValue set f
  • 为什么“try”是一个明确的关键字?

    在我所知道的所有异常感知语言 C Java C Python Delphi Pascal PHP 中 捕获异常需要显式try块后跟catch块 我经常想知道其技术原因是什么 为什么我们不能直接追加catch普通代码块的子句 作为一个C 的例
  • 添加从 Unity for Android studio 导出的 2 个模块出现错误:“错误:程序类型已存在:bitter.jnibridge.JNIBridge”

    我在 Android Studio 中的 Kotlin 中有一个 android 项目 以及 2 个 Unity 模块 像使用 Unity 的 android studio 的项目一样导出 我想在我的项目中使用它们 但我收到错误 错误 程序
  • 最大非空列

    我需要使用基于两个 DATETIME 列的最大值的公式更新一行 我通常会这样做 GREATEST date one date two 但是 两列都允许为 NULL 即使另一个为 NULL 我也需要最大的日期 当然 当两者都为 NULL 时
  • JSON 文件中数据的所有可能组合

    我的目标是创建一部分代码 该部分代码将使用 JSON 文件中的数据生成所有可能的组合 而不会重复 具有相同元素的组合 无论其顺序是什么 我的 JSON 文件如下所示 COLLECTION Assault WEAPON SG 553 SKIN
  • 如何在 Hive 中将字符串转换为毫秒时间戳

    我有一个字符串 20141014123456789 它代表一个毫秒时间戳 我需要将其转换为 Hive 中的时间戳 0 13 0 而不丢失毫秒 我尝试了这个 但 unix timestamp 返回一个整数 所以我丢失了毫秒 from unix
  • jQuery Ajax 调用返回“[object XMLDocument]”

    我有一个 HTML 页面 我想使用 Ajax 填充该页面 我已经从其他页面复制了代码 这些都是 PHP 语言 我不确定这是否重要 并且它正在返回 object XMLDocument 在其他页面 PHP 页面 中 我得到了在例程中打印出来的
  • 使用 apriori 算法进行推荐

    So a 最近的问题 https stackoverflow com questions 1248373 apriori algorithm让我意识到相当酷先验算法 http en wikipedia org wiki Apriori al
  • 好吧,我们可以在 javascript 中拥有私有标识符,但是受保护的标识符又如何呢?

    就这么简单 我们能以某种方式模拟 Javascript 中的 受保护 可见性吗 Do this Note Do not break touch this object code 或者通过谷歌在第一页找到这个 http blog blanqu
  • RESTful API 设计:使用 PUT 或 POST 创建多对多关系?

    在设计和创建 RESTful API 时 会出现以下问题 该 API 支持 GET 用于查询 POST 用于创建 PUT 用于更新 和 DELETE 用于删除 假设数据库中有一个article and a shop两者都已经存在 现在我们需
  • 改造时出现 401 未经授权的错误?

    Error 401 unauthorized表示请求因凭据无效而被拒绝 我正在请求httpsURL 使用改造并获取401 unauthorized在做的时候curl https external email protected cdn cg
  • XML 反序列化失败

    我正在反序列化以下 XML 文件 使用 XML 序列化器与 VSTS 2008 C Net 3 5 这是 XML 文件
  • Nodejs 错误:生成 ENOENT

    我是nodejs的新手 我正在尝试运行它 我得到 events js 72 throw er Unhandled error event Error spawn ENOENT at errnoException child process