What version of pkg are you using?
6.7.0
What version of Node.js are you using?
24.10.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?
node22-win-x64
Describe the Bug
the dependence have is-generator-function ^1.1.2 package, then, the build exe file exec error.
pkg/prelude/bootstrap.js:1876
throw error;
^
Error: Cannot find module 'C:\snapshot\pkg-issue-module-not-found-demo\node_modules\generator-function\require.mjs'
- 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:1423:15)
at finalizeEsmResolution (node:internal/modules/cjs/loader:1412:15)
at resolveExports (node:internal/modules/cjs/loader:654:14)
at Function._findPath (node:internal/modules/cjs/loader:721:31)
at Function. (node:internal/modules/cjs/loader:1373:27)
at Function._resolveFilename (pkg/prelude/bootstrap.js:1959:46)
at defaultResolveImpl (node:internal/modules/cjs/loader:1029:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1034:22)
at Function._load (node:internal/modules/cjs/loader:1196:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14) {
code: 'MODULE_NOT_FOUND',
path: 'C:\snapshot\pkg-issue-module-not-found-demo\node_modules\generator-function',
pkg: true
}
Expected Behavior
expect the exe file can exec success.
To Reproduce
- create one empty npm package
npm init
- install the packge:
npm install is-generator-funciton@^1.1.2
- create index.js write code
require('is-generator-function')
- build by pkg
pkg index.js --options experimental-require-module --target=node22-win-x64 -o test.exe
- exec the
./test.exe
the package.json:
{
"name": "pkg-issue-module-not-found-demo",
"version": "1.0.0",
"description": "",
"license": "ISC",
"author": "",
"type": "commonjs",
"main": "index.js",
"scripts": {
"test": "node index.js",
"build": "pkg index.js --options experimental-require-module --target=node22-win-x64 -o test.exe"
},
"dependencies": {
"is-generator-function": "^1.1.2"
},
"devDependencies": {
"@yao-pkg/pkg": "^6.7.0"
},
"pkg": {
"assets": [
"./node_modules/is-generator-function/**/*.js",
"./node_modules/is-generator-function/**/*.json",
"./node_modules/generator-function/**/*.json",
"./node_modules/generator-function/**/*.js",
"./node_modules/generator-function/**/*.mjs"
]
}
}
What version of pkg are you using?
6.7.0
What version of Node.js are you using?
24.10.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?
node22-win-x64
Describe the Bug
the dependence have
is-generator-function ^1.1.2package, then, the build exe file exec error.pkg/prelude/bootstrap.js:1876
throw error;
^
Error: Cannot find module 'C:\snapshot\pkg-issue-module-not-found-demo\node_modules\generator-function\require.mjs'
at createEsmNotFoundErr (node:internal/modules/cjs/loader:1423:15)
at finalizeEsmResolution (node:internal/modules/cjs/loader:1412:15)
at resolveExports (node:internal/modules/cjs/loader:654:14)
at Function._findPath (node:internal/modules/cjs/loader:721:31)
at Function. (node:internal/modules/cjs/loader:1373:27)
at Function._resolveFilename (pkg/prelude/bootstrap.js:1959:46)
at defaultResolveImpl (node:internal/modules/cjs/loader:1029:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1034:22)
at Function._load (node:internal/modules/cjs/loader:1196:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14) {
code: 'MODULE_NOT_FOUND',
path: 'C:\snapshot\pkg-issue-module-not-found-demo\node_modules\generator-function',
pkg: true
}
Expected Behavior
expect the exe file can exec success.
To Reproduce
npm initnpm install is-generator-funciton@^1.1.2require('is-generator-function')pkg index.js --options experimental-require-module --target=node22-win-x64 -o test.exe./test.exethe package.json: