Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solgraph throws TypeError: _commander.default.version is not a function #51

Open
lmanini opened this issue Jun 1, 2024 · 2 comments
Open
Labels

Comments

@lmanini
Copy link

lmanini commented Jun 1, 2024

Running node v16.20.2, just installed solgraph and am facing an error with following trace:

var program = _commander["default"].version(_package["default"].version).arguments('<file>').usage(extendedHelp).parse(process.argv);
                                    ^

TypeError: _commander.default.version is not a function
    at Object.<anonymous> (/home/ljmanini/.nvm/versions/node/v16.20.2/lib/node_modules/solgraph/dist/bin.js:9:37)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
    at Module.require (node:internal/modules/cjs/loader:1100:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/home/ljmanini/.nvm/versions/node/v16.20.2/lib/node_modules/solgraph/solgraph.js:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
@raineorshine
Copy link
Owner

Sorry, this library is no longer maintained. You could try running on an older version of node.

@KaePee
Copy link

KaePee commented Jan 10, 2025

Same issue. I modified the commander module in bin.js to support newer node versions. Replace <path/to/node_version>/solgraph/dist/bin.js with:

"use strict";

var { Command } = require("commander");
var _package = _interopRequireDefault(require("../package.json"));
var _index = _interopRequireDefault(require("./index.js"));
var _fs = require("fs");

function _interopRequireDefault(e) {
  return e && e.__esModule ? e : { default: e };
}

var extendedHelp = `
${_package["default"].description}

Example:
$ cat MyContract.sol | solgraph > MyContract.dot
$ solgraph MyContract.sol > MyContract.dot
`;

//new instance of Command API
var program = new Command();
program
  .version(_package["default"].version)
  .arguments("[file]")
  .usage(extendedHelp)
  .parse(process.argv);

var inputPromise;

if (program.args[0]) {
  inputPromise = new Promise(function (resolve, reject) {
    (0, _fs.readFile)(program.args[0], "utf-8", function (err, data) {
      if (err) {
        return reject(err);
      }
      resolve(data);
    });
  });
} else {
  inputPromise = new Promise((resolve, reject) => {
    const stdin = process.stdin;
    let data = "";

    stdin.setEncoding("utf-8");

    stdin.on("data", (chunk) => {
      data += chunk;
    });

    stdin.on("end", () => {
      if (data.trim() === "") {
        return reject(new Error("No input provided via stdin or file."));
      }
      resolve(data);
    });

    stdin.on("error", (err) => {
      reject(err);
    });
  });
}

inputPromise
  .then(function (source) {
    console.log((0, _index["default"])(source));
  })
  .catch(function (err) {
    console.error(err.message);
    process.exit(1);
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants