I made a nodeJS app using puppeteer-extra and some puppeteer-extra-plugins, debugging the source code works just fine. It also runs OK when I pack it into an .exe file using https://www.npmjs.com/package/pkg.
However, when the .exe is moved to a different directory than the 'output' directory, I'm getting the error
Cannot find module 'debug'
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.
I never use the debug module, it must be required internally by some of my dependencies... but how can I handle this error?
I've got these requires
const puppeteer = require(path.join(process.cwd(), 'dependencies', 'puppeteer-extra'));
const StealthPlugin = require(path.join(process.cwd(), 'dependencies', 'puppeteer-extra-plugin-stealth'));
const RecaptchaPlugin = require(path.join(process.cwd(), 'dependencies', 'puppeteer-extra-plugin-recaptcha'));
const UserPrefsPlugin = require(path.join(process.cwd(), 'dependencies', 'puppeteer-extra-plugin-user-preferences'));
and my package.json (config for pkg)
"pkg": {
"scripts": [
"node_modules/puppeteer/lib/*.js"
],
"assets": [
"./node_modules/@types",
"./node_modules/typescript/lib/*.d.ts",
"src/**/*.ts",
"./tsconfig.json"
],
"targets": [
"node8-win32"
]
}