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.

It seems that pkg is not compatible with Axios! #1936

Closed

Description

@AlirezaEthDev

What version of pkg are you using?

5.8.1

What version of Node.js are you using?

18.15.0

What operating system are you using?

Windows

What CPU architecture are you using?

x64

What Node versions, OSs and CPU architectures are you building for?

node18-win-x64

Describe the Bug

There is Axios module in my NodeJS source code as a required module. Whenever I try to export Node code as an exe file by:
pkg app.js --update-base --targets node18-win-x64
It does its job but by the below warnings printed on PowerShell:

> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\axios.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\utils.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\bind.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\core\Axios.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\core\mergeConfig.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\defaults\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\formDataToJSON.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\cancel\CanceledError.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\cancel\CancelToken.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\cancel\isCancel.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\env\data.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\toFormData.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\core\AxiosError.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\spread.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\isAxiosError.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\HttpStatusCode.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\p-cancelable\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\buildURL.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\core\InterceptorManager.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\core\dispatchRequest.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\core\buildFullPath.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\validator.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\defaults\transitional.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\toURLEncodedForm.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\platform\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\platform\node\classes\FormData.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\parseHeaders.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\AxiosURLSearchParams.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\core\transformData.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\adapters\adapters.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\isAbsoluteURL.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\combineURLs.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\platform\node\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\adapters\http.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\adapters\xhr.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\platform\node\classes\URLSearchParams.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\core\settle.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\fromDataURI.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\AxiosTransformStream.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\formDataToStream.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\readBlob.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\ZlibHeaderTransformStream.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\cookies.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\isURLSameOrigin.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\parseProtocol.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\speedometer.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\NodeExport\node_modules\axios\lib\helpers\throttle.js

In first, I tried pkg by the latest version of axios but after that I downgraded axios previous versions.

Expected Behavior

The exe file created without any warning about axios module.

To Reproduce

Trying this command on PowerShell:
pkg app.js --update-base --targets node18-win-x64

Activity

  1. robertsLando commented on May 21, 2023

    @robertsLando
    Contributor

    Starting from axios 1.0.0 uses esm and pkg doesn't support them yet

  2. grootgordon commented on May 22, 2023

    @grootgordon

    In my case, I try to downgrade axios from 1.3.4 to 0.27.2, it's ok.

    more info you can read issue641

  3. AlirezaEthDev commented on May 23, 2023

    @AlirezaEthDev
    Author

    In my case, I try to downgrade axios from 1.3.4 to 0.27.2, it's ok.

    more info you can read issue641

    Yes, I did it and it worked. But 0.27.2 is too old.

  4. xreyc commented on Jul 11, 2023

    @xreyc

    compile the javascript first using ncc before using pkg.

    "scripts": {
    "test": "jest",
    "start": "node src/index.js",
    "dev": "nodemon src/index.js",
    "build": "ncc build -o build/lib index.js && pkg --target node18-win-x64 -o build/server-interface.exe ./build/lib/index.js"
    },

  5. added a commit that references this issue on Oct 25, 2023
  6. manikanta-kondeti commented on Oct 30, 2023

    @manikanta-kondeti

    so the solution to make pkg work here is to downgrade axios to 0.27.2? or is there any update?

  7. mattkrins commented on Dec 4, 2023

    @mattkrins

    so the solution to make pkg work here is to downgrade axios to 0.27.2? or is there any update?

    Nope. ESM support likely to never come: yao-pkg#5 (comment)

  8. robertsLando commented on Dec 5, 2023

    @robertsLando
    Contributor

    In order to use axios latest just add this to your scripts in package.json:

     "pkg": {
        "scripts": [
          "node_modules/axios/dist/node/*",
    		[...]
        ],
    
  9. SDGSnS commented on Dec 20, 2023

    @SDGSnS

    we solved the problem taking the CommonJS library from axios/dist ( *.cjs and *.cjs.map files) under a "lib" directory under the project root files, and requiring the axios library from there instead of using the usual require, later on removing the "axios" package from the project.

    This workaround solved our issue...

    we are working with node 18.18.0 and pkg node 18.5 (think is the latest supported?)

  10. robertsLando commented on Dec 21, 2023

    @robertsLando
    Contributor

    Last supported is v20: https://github.com/yao-pkg/pkg

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