Unitech/pm2 · critical · Error
Could not _load() the script
Error message
Could not _load() the script
What it means
ProcessContainerFork.js is the wrapper process PM2 forks for each app instance. It reads process.env.pm_exec_path and loads the user's script via import() (ESM) or module._load() (CJS). If pm_exec_path is missing or falsy there is no script to run, so the forked wrapper throws.
Source
Thrown at lib/ProcessContainerFork.js:35
if (process.connected &&
process.send &&
process.versions &&
process.versions.node)
process.send({
'node_version': process.versions.node
});
// Require the real application
if (process.env.pm_exec_path) {
if (ProcessUtils.isESModule(process.env.pm_exec_path) === true) {
import(url.pathToFileURL(process.env.pm_exec_path));
}
else
require('module')._load(process.env.pm_exec_path, null, true);
}
else
throw new Error('Could not _load() the script');
// Change some values to make node think that the user's application
// was started directly such as `node app.js`
process.mainModule = process.mainModule || {};
process.mainModule.loaded = false;
require.main = process.mainModule;
View on GitHub (pinned to 31adee8048)
Solutions
- Delete and re-add the affected app: `pm2 delete <app>` then `pm2 start <entry>`.
- Clear and regenerate the dump: stop everything, `pm2 save` once after a clean start.
- Ensure your ecosystem/script path resolves to an existing file before starting.
Defensive patterns
Strategy: fallback
Validate before calling
if (!process.env.pm_exec_path) {
console.error('pm_exec_path missing; refusing to fork a wrapper with no script');
process.exit(1);
} Try / catch
try {
pm2.start(app, cb);
} catch (e) {
if (/Could not _load\(\) the script/.test(e.message)) {
pm2.delete(app.name, () => pm2.start(app, cb)); // reset and re-add
} else { throw e; }
} Prevention
- After upgrading PM2, regenerate the dump (pm2 save) to avoid resurrecting stale envs.
- Delete and re-add apps whose entry paths have changed.
- Treat a missing pm_exec_path as a signal of dump corruption — start clean.
When it happens
Trigger: PM2 forks a worker but the environment was not seeded with pm_exec_path — typically an internally inconsistent state: corrupted dump file, a process resurrected from an older PM2 version, or programmatic launch with an incomplete env.
Common situations: Resurrecting a dump.json saved by an incompatible/older PM2; manually constructed process envs; an app entry whose path failed to resolve before fork.
Related errors
AI-assisted analysis of Unitech/pm2@31adee8048 (2026-08-13).
Data as JSON: /api/errors/4a616b9acc3aa806.
Report an issue: GitHub.