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-windows-x64
Describe the Bug
I'm getting this error when executing my packaged project that uses axios.
pkg/prelude/bootstrap.js:1872
throw error;
^
Error: Cannot find module 'C:\snapshot\my-app\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:967:15)
at finalizeEsmResolution (node:internal/modules/cjs/loader:960:15)
at resolveExports (node:internal/modules/cjs/loader:488:14)
at Module._findPath (node:internal/modules/cjs/loader:528:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:932:27)
at Function._resolveFilename (pkg/prelude/bootstrap.js:1951:46)
at Module._load (node:internal/modules/cjs/loader:787:27)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at Module.require (pkg/prelude/bootstrap.js:1851:31)
at require (node:internal/modules/cjs/helpers:102:18) {
code: 'MODULE_NOT_FOUND',
path: 'C:\\snapshot\\my-app\\node_modules\\axios\\package.json',
pkg: true
}
Node.js v18.5.0
I belive the problem is that pkg only packages the esm code of axios and not the whole folder, but my project is in commonJS.
This is part of the package.json file of the axios package.
The main points to index.js and as nothing requires dist/node/axios.cjs it's not included in the final package.
To import the package in my code I use require(axios).
I was able to fix the problem by adding a new dictionary file for axios : axios.js :
What version of pkg are you using?
5.8.1
What version of Node.js are you using?
18.19.0
What operating system are you using?
Windows
What CPU architecture are you using?
x86_64
What Node versions, OSs and CPU architectures are you building for?
node18-windows-x64
Describe the Bug
I'm getting this error when executing my packaged project that uses axios.
I belive the problem is that pkg only packages the esm code of axios and not the whole folder, but my project is in commonJS.
This is part of the
package.json
file of the axios package.The main points to
index.js
and as nothing requiresdist/node/axios.cjs
it's not included in the final package.To import the package in my code I use
require(axios)
.I was able to fix the problem by adding a new dictionary file for axios :
axios.js
:This did solve my problem and I was hoping it could be added in a future version.
Expected Behavior
Application runs without errors using axios module in a common js project.
To Reproduce
Create a new common js node project with axios as a dependency.
Package project using pkg and run the packaged application.
The text was updated successfully, but these errors were encountered: