What could possibly be causing this "write EOF" error after typing the "npx webpack" command?

Viewed 2166

Okay, I have a webpack project that I want to build/compile. My package.json is here:

{
"name": "project-name",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
    "build": "webpack"
},
"author": "",
"license": "ISC",
"devDependencies": {
    "chokidar": "3.4.0",
    "clean-webpack-plugin": "^3.0.0",
    "closure-webpack-plugin": "^2.3.0",
    "copy-webpack-plugin": "^5.1.1",
    "google-closure-compiler": "^20200504.0.0",
    "lodash": "^4.17.19",
    "minimatch": "^3.0.4",
    "raw-loader": "^4.0.1",
    "terser-webpack-plugin": "^3.0.1",
    "uglify-loader": "^3.0.0",
    "webpack": "^4.43.0",
    "webpack-cli": "^3.3.12",
    "webpack-obfuscator": "^0.28.0",
    "zip-folder": "^1.0.0"
},
"dependencies": {
    "crypto-js": "^4.0.0",
    "jquery": "^3.5.1",
    "prettier": "^2.0.5",
    "semver": "^7.3.2",
    "sweetalert": "^2.1.2",
    "sync-request": "^6.1.0",
    "versioning": "^1.1.0",
    "webpack-build-notifier": "^2.0.0",
    "webpack-closure-compiler": "^2.1.6"
}
}

When running the command "npm i", the node_modules folder is being created and at the end there are warns informing me that some modules are deprecated like "minimatch@0.3.0", "gulp-util@3.0.8", "fsevents@1.2.13" etc. Also it gives me warns that say optional dependencies have been skipped. Dependencies such as "fsevents@^2.1.2" etc. Now I read somewhere else that if they're optional, then it shouldn't matter.. right?

Anyway, when typing the "npx webpack" command expecting my files to get compiled and placed in the "out" folder, I'm getting this error:

 Error: write EOF
       at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:94:16)

Now, I could not find anything like this anywhere on the internet. I've been searching for weeks now, and still haven't found any fix. The project that I'm trying to compile is open-source and is not mine. I barely know what I'm doing to be honest, I only know how to edit certain parts of code and stuff like that, nothing anyone else couldn't figure out.

This project used to always compile normally on my previous Windows 7 (64-bit) on the same PC. Now I have a different Windows 7 (32-bit) and this issue just popped up out of nowhere. I'm assuming there is something wrong with node, npm or whatever else, not the actual project. Because like I said, it used to compile with no problems. Also, I have node installed, python installed and chocolatey could not be installed because of issues with PowerShell and something about SecurityProtocol, but I don't think chocolatey is necessary, is it?

Lastly, here's the webpack.config.js file if that might help also:

var path = require("path")
var JavaScriptObfuscator = require("webpack-obfuscator")
var CopyWebpackPlugin = require("copy-webpack-plugin")
var { CleanWebpackPlugin } = require("clean-webpack-plugin")
var WebpackBuildNotifierPlugin = require("webpack-build-notifier")
var ClosureCompilerPlugin =
    process.platform == "win32"
        ? require("webpack-closure-compiler")
        : require("closure-webpack-plugin")
var zipFolder = require("zip-folder")
var CryptoJS = require("crypto-js")
var fs = require("fs")
var manifest
try {
    manifest = require("./src/resp/data.json")
} catch (e) {
    fs.writeFileSync("./src/resp/data.json", "{}")
    manifest = {}

}
var version = (manifest.version = "2.1.7")

var time = new Date()

var string = (manifest.secret =
    Buffer.from(
        (
            (new Date().getDate() + new Date().getMonth()) *
            Math.pow(new Date().getFullYear(), 2)
        ).toString(32)
    )
        .toString("base64")
        .replace(/[^a-zA-Z]/g, "") +
    (new Date().getSeconds() + new Date().getMinutes()))

fs.writeFileSync("src/resp/data.json", JSON.stringify(manifest))

var dataURL = file => {
    var file =
        "data:image/png;base64," + fs.readFileSync(file).toString("base64")

    return CryptoJS.AES.encrypt(file, string)
}
var config = {
    entry: {
        main: "./src/resp/index.js",
        background: "./src/background.js",
        content: "./src/content.js",
    },
    output: {
        filename: "[name].js",
        chunkFilename: "chunks/[chunkhash:8].something.js",
        path: path.resolve("./out/"),
    },
    plugins: [
        new ClosureCompilerPlugin(
            process.platform == "win32"
                ? undefined
                : {
                    platform: "native",
                }
        ),
        new CopyWebpackPlugin([
            {
                from: "src",
                ignore: ["*.js", "*.txt", "data.json", "*.dev.*"],
                transform: (content, path) => {
                    if (
                        path.match(/\.png|\.jpg|\.gif/g) &&
                        !path.match(/\.enc\./g)
                    )
                        return content

                    var parse = [
                        {
                            from: /[0-9]+\.[0-9]+\.[0-9]+/g,
                            to: version,
                        },
                    ]

                    content = content.toString()

                    if (!path.match(/\.png|\.jpg|\.gif/g))
                        parse.forEach(p => {
                            content = content.replace(p.from, p.to)
                        })
                    if (path.match(/\.enc\.png/g))
                        content = dataURL(path).toString()

                    return Buffer.from(content)
                },
                transformPath: path => {
                    return path.replace(/\.enc\.png/g, ".enci")
                },
            },
        ]),
        new CleanWebpackPlugin(),
        {
            apply: compiler => {
                compiler.hooks.afterEmit.tap("AfterEmitPlugin", compilation => {
                    zipFolder("./out", "./zip/latest.zip", new Function())
                    zipFolder(
                        "./out",
                        "./zip/" +
                        `${time.getMonth()+1}-${time.getDate()}-${time.getFullYear()}.${Buffer.from(
                            time.getMilliseconds().toString(32)
                        )
                            .toString("base64")
                            .replace(/[^0-9a-zA-Z]/g, "")
                            .substr(0, 6)}.zip`,
                        new Function()
                    )
                })
            },
        },
        new WebpackBuildNotifierPlugin({
            title: "game v" + version + " Build (" + string + ")",
            suppressWarning: true,
        }),
    ],
    /*optimization: {
        splitChunks: {
            chunks: "all"
        }
    },*/
    module: {
        rules: [
            {
                test: /parse\.js|\.txt/i,
                use: ["raw-loader"],
            },
        ],
        noParse: [/[\/\\]node_modules[\/\\]jquery[\/\\].+?$/],
    },
    stats: "errors-only",
}


module.exports = (env, argv) => {

if (argv.mode !== 'development') {
    config.plugins.splice(1,0,new JavaScriptObfuscator(
        {
            //identifierNamesGenerator: "mangled",
            //rotateUnicodeArray: true,
            //deadCodeInjection: true,
            //unicodeEscapeSequence: true,
            //selfDefending: true,
            //transformObjectKeys: true,
            //disableConsoleOutput: true
        },
        ["content.js"]
    ))
}

return config;
};

I'm really losing hope, there's no communication with the project author. He only updates the source every now and then, but he doesn't want to help at all so I'm pretty much on my own with this issue. Please if you have any idea what could possibly be causing the weird error when typing the "npx webpack" command, comment down below. Also, it's not just npx webpack that fails, I tried the "npm run-script build" command too and it gives the same error + err! code "LIFECYCLE".

EDIT: Apparently didn't have java sdk 8 installed, fixed the issue.

0 Answers
Related