You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What Node versions, OSs and CPU architectures are you building for?
node18
Describe the Bug
When attempting to package a Node.js application that uses the axios library (version 1.6.3), the pkg command fails to create functional single executable and issues warnings about not being able to generate bytecode for axios files.
Steps to Reproduce:
Include axios version 1.6.3 in your project's dependencies.
Utilize axios in your application.
Run the packaging command: pkg . -t node18-macos-x64.
The application should be successfully packaged into binaries as specified in the main and exports fields the package.json
To Reproduce
The single executables are created, and the following warnings are displayed:
> Warning Failed to make bytecode node18-x64 for file /snapshot/bright-cli/node_modules/axios/lib/platform/node/classes/URLSearchParams.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/bright-cli/node_modules/axios/lib/helpers/throttle.js
However, while running the single executable, it prints the following error message:
Error: Cannot find module '/snapshot/bright-cli/node_modules/axios/dist/node/axios.cjs'
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
at createEsmNotFoundErr (node:internal/modules/cjs/loader:1171:15)
at finalizeEsmResolution (node:internal/modules/cjs/loader:1159:15)
at resolveExports (node:internal/modules/cjs/loader:584:14)
at Module._findPath (node:internal/modules/cjs/loader:658:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1120:27)
at Function._resolveFilename (pkg/prelude/bootstrap.js:1955:46)
at Module._load (node:internal/modules/cjs/loader:975:27)
at Module.require (node:internal/modules/cjs/loader:1225:19)
at Module.require (pkg/prelude/bootstrap.js:1851:31)
at require (node:internal/modules/helpers:177:18) {
code: 'MODULE_NOT_FOUND',
path: '/snapshot/bright-cli/node_modules/axios/package.json',
pkg: true
}
The text was updated successfully, but these errors were encountered:
@robertsLando I see. However, Axios, like many other dependencies, uses the exports field to declare multiple artifacts for both CommonJS and ESM. Adding support for ESM does not resolve the issue with loading CommonJS entries declared in the exports field.
What version of pkg are you using?
5.11.5
What version of Node.js are you using?
18.20.2
What operating system are you using?
macOS
What CPU architecture are you using?
x86_64
What Node versions, OSs and CPU architectures are you building for?
node18
Describe the Bug
When attempting to package a Node.js application that uses the axios library (version 1.6.3), the
pkg
command fails to create functional single executable and issues warnings about not being able to generate bytecode for axios files.Steps to Reproduce:
pkg . -t node18-macos-x64
.Similar tickets: vercel#2042 and vercel#1873
Expected Behavior
The application should be successfully packaged into binaries as specified in the
main
andexports
fields the package.jsonTo Reproduce
The single executables are created, and the following warnings are displayed:
However, while running the single executable, it prints the following error message:
The text was updated successfully, but these errors were encountered: