Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js require(";jpgJs";)在我的nodejs项目中返回一个空的{}_Node.js_Webpack_Requirejs_Jpeg - Fatal编程技术网

Node.js require(";jpgJs";)在我的nodejs项目中返回一个空的{}

Node.js require(";jpgJs";)在我的nodejs项目中返回一个空的{},node.js,webpack,requirejs,jpeg,Node.js,Webpack,Requirejs,Jpeg,require(“jpgJs”)在我的nodejs项目中返回一个空的{} 我在我的react项目中使用它,它作为依赖项 在代码中,jpgjs似乎没有设置它的module.exports 在jpg.js的第102行 if (typeof exports === "function") { module.exports = { JpegImage: JpegImage, JpegDecoder: JpegDecoder, JpxDecoder:

require(“jpgJs”)
在我的nodejs项目中返回一个空的
{}

我在我的react项目中使用它,它作为依赖项

在代码中,
jpgjs
似乎没有设置它的
module.exports

jpg.js的第102行

if (typeof exports === "function") {
    module.exports = {
        JpegImage: JpegImage,
        JpegDecoder: JpegDecoder,
        JpxDecoder: JpxDecoder,
        Jbig2Decoder: Jbig2Decoder
    };
}
它永远不会进入
if语句中。如果我强制它进入该代码,
JpegDecoder
(片段
Utif
需要)被设置为
undefined

如果我搬家

module.exports = {
    JpegImage: JpegImage,
    JpegDecoder: JpegDecoder,
    JpxDecoder: JpxDecoder,
    Jbig2Decoder: Jbig2Decoder
};
jpg.js
的最后,它将
jpegDecoder
设置为正确的值,我可以从我的代码中要求它,但是
Utif
中的require调用不起作用

有没有人在节点项目中使用过jpgjs,并看到过这个问题


谢谢

如果其他人需要答案,我会把JPGJ分给我的github,然后进行我需要的修复。我向jpgjs提交了一个请求,但他们没有响应


if语句应该检查exports==“object”,并且应该在定义它所导出的元素之后

我没有使用它,但这似乎是一个主要的错误。我会在github上提交一个关于这一点的问题,因为在任何环境中,
导出
都不应该是一个
函数
。如果存在一个防止所有模块使用的问题,那么对于其他代码的完整性,我会持怀疑态度,并且会考虑选择另一个依赖项来代替。编辑我明白了。我相信这段代码也是从mozilla/pdfjs派生出来的,所以这也是他们系统中的一个bug,对吗?没关系,我看到mozilla分叉了JPGJ,看起来他们做了一些额外的更改。