Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Unable to compile app with -r esm #954

Closed

Description

@acidos

I am using esm module for running my app. This is how I ran it.

"scripts": {
    "start": "node -r esm src/index.js",

Now when I try to compile my app using pkg with the following line

pkg src/index.js -t node12-macos-x64 --options require=esm

I am getting the following errors for every file

TypeError: require(...).internalModuleStat is not a function
    at internalModuleStat (internal/modules/cjs/loader.js:59:64)
    at stat (internal/modules/cjs/loader.js:143:18)
    at Function.Module._findPath (internal/modules/cjs/loader.js:630:20)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:951:27)
    at Function.Module._load (internal/modules/cjs/loader.js:840:27)
    at Module.require (internal/modules/cjs/loader.js:1024:19)
    at Module._preloadModules (internal/modules/cjs/loader.js:1276:12)
    at loadPreloadModules (internal/bootstrap/pre_execution.js:444:5)
    at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:76:3)
    at internal/bootstrap/pkg.js:7:1
> Warning Failed to make bytecode node12-x64 for file /snapshot/srv/node_modules/accepts/index.js

Activity

  1. hasparus commented on Sep 12, 2020

    @hasparus

    Hey @acidos, I'm getting the same error when running hasura metadata export in Hasura CLI.
    This is the only place I could find. Have you found a root cause of the problem? Something wrong with Node installation?

  2. acidos commented on Sep 12, 2020

    @acidos
    Author

    @hasparus no, I gave up...

  3. marikaner commented on Sep 23, 2020

    @marikaner

    I had the same issue and it was only happening when I ran it from the terminal in VSCode. In a separate terminal it worked. (Changing the shell in VSCode didn't help either).

  4. SnakeDrak commented on Nov 3, 2020

    @SnakeDrak
    Contributor

    It seems NODE_OPTIONS is read by the node inside of the pkg, so if you have any special option or bootstrap included on that environment variable, it could generate conflicts with the node inside the pkg (with the debugger, for example).

    In my case, that NODE_OPTIPONS was in my particular environment defined by VSCode because I was debugging on that moment. I don't know the reason because VSCode defined the variable in my session, maybe it is related to some particular configuration of the debug options.

    I saw some errors related to that: require(...).internalModuleStat is not a function and ERR_INSPECTOR_NOT_AVAILABLE. However, multiple errors could be generated, it depends of each NODE_OPTIONS.

    Another example of this, on this issue in graphql-engine, solved removing the environment variable.

    I don't know if vercel/pkg/@igorklopov want to remove this feature, because it could be useful. However, I will make a PR to include it on the documentation.

  5. hipstersmoothie commented on Mar 25, 2021

    @hipstersmoothie
    Contributor

    closing duplicate of #782

  6. added a commit that references this issue on May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions