Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

prybar-nodejs fails with ES Modules #83

Description

@sflanker

In Node.js 16+ it is possible to have a package entry point be an ECMA Script module. However when you try to run prybar-nodejs -i index.js with such a package it fails to load the specified file with the following error:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:119:11)
    at Object.basename (node:path:1309:5)
    at Error.<anonymous> (node:internal/errors:1459:55)
    at getMessage (node:internal/errors:421:12)
    at new NodeError (node:internal/errors:348:21)
    at Module._extensions..js (node:internal/modules/cjs/loader:1128:19)

If I change the filename to index.mjs I get the following:

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/Node16Repl/index.mjs not supported.
Instead change the require of /home/runner/Node16Repl/index.mjs to a dynamic import() which is available in all CommonJS modules.
    at runModule (/nix/store/af4zlyjyr5wajad3k1kyrj2abrqra7xl-prybar-nodejs-0.0.0-a584d8e/prybar_assets/nodejs/module-context-hook.js:191:3)
    at Object.<anonymous> (/tmp/prybar-nodejs-349568109.js:200:5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions