Skip to content

EISDIR: illegal operation on a directory Error #31

@alpisa

Description

@alpisa

I'm getting the same error as here, I've tried the solutions but they didn't work for me and I'm recreating it because the issue is closed.

#22

Error:

>unpack output C:\Users\windows\Desktop\source\static\js\main.60f996d4.chunk.js.map
Unpacking 🛍  your source maps 🗺
node:fs:590
  handleErrorFromBinding(ctx);
  ^

Error: EISDIR: illegal operation on a directory, open 'C:\Users\alperen.saylar\cikmis\'
    at Object.openSync (node:fs:590:3)
    at Object.writeFileSync (node:fs:2202:35)
    at C:\Users\alperen.saylar\AppData\Roaming\npm\node_modules\source-map-unpack\dist\index.js:47:16
    at Array.forEach (<anonymous>)
    at C:\Users\alperen.saylar\AppData\Roaming\npm\node_modules\source-map-unpack\dist\index.js:42:17
    at C:\Users\alperen.saylar\AppData\Roaming\npm\node_modules\source-map-unpack\node_modules\source-map\lib\source-map-consumer.js:78:16 {
  errno: -4068,
  syscall: 'open',
  code: 'EISDIR',
  path: 'C:\\Users\\alperen.saylar\\cikmis\\'
}

I invested in the arrangement called here #23 but the problem persists:

if (!fs.existsSync(pathToProject)) {
	console.log()
    // Create project dir if it doesn't exist
    try {
        fs.mkdirSync(projectNameInput,'0777', true)
    } catch (err) {
        console.log(chalk.red(`Couldn't create project at: ${pathToProject}, please, check your permissions`))
    }

    console.log(chalk.red(`Project created at: ${pathToProject}`))
    console.log()
    process.exit()
}

The full code is as follows:

#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var fs = require("fs");
var path = require("path");
var chalk = require("chalk");
var mkdirp = require("mkdirp");
var minimist = require("minimist");
var source_map_1 = require("source-map");
var argv = minimist(process.argv.slice(2));
var projectNameInput = argv._[0];
var mapInput = argv._[1];
if (!projectNameInput || !mapInput) {
    console.log();
    console.log(chalk.white('Usage: unpack'), chalk.green('<folder-name-to-unpack-files-to)> <path-to-map-file>'));
    console.log();
    console.log(chalk.blue('Note: Minified javascript file should be placed under path specified in .map file.'));
    console.log();
    process.exit();
}
var pathToProject = path.join(process.cwd(), projectNameInput);
var pathToMap = path.isAbsolute(mapInput)
    ? mapInput
    : path.join(process.cwd(), mapInput);
if (!fs.existsSync(pathToProject)) {
	console.log()
    // Create project dir if it doesn't exist
    try {
        fs.mkdirSync(projectNameInput,'0777', true)
    } catch (err) {
        console.log(chalk.red(`Couldn't create project at: ${pathToProject}, please, check your permissions`))
    }

    console.log(chalk.red(`Project created at: ${pathToProject}`))
    console.log()
    process.exit()
}
if (!fs.existsSync(pathToMap)) {
    console.log();
    console.log(chalk.red("Can't find map file under : " + pathToMap));
    console.log();
    process.exit();
}
try {
    var mapFile = fs.readFileSync(pathToMap, 'utf8');
    source_map_1.SourceMapConsumer.with(mapFile, null, function (consumer) {
        console.log(chalk.green("Unpacking \uD83D\uDECD  your source\u00A0maps \uD83D\uDDFA"));
        var sources = consumer.sources;
        sources.forEach(function (source) {
            var WEBPACK_SUBSTRING_INDEX = 11;
            var content = consumer.sourceContentFor(source);
            var filePath = process.cwd() + "\\" + projectNameInput + "\\" + source.substring(WEBPACK_SUBSTRING_INDEX);
            mkdirp.sync(path.dirname(filePath));
            fs.writeFileSync(filePath, content);
        });
        console.log(chalk.green('🎉  All done! Enjoy exploring your code 💻'));
    });
}
catch (err) {
    console.log(chalk.red('Oops! Something is wrong with the source map'), err);
    console.log(chalk.red('Make sure .min.js is correctly placed under the path specified in .map file'));
    console.log('STDERR: ');
    console.log(err);
}
//# sourceMappingURL=index.js.map

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions