Set PUPPETEER_TMP_DIR in the PM2 ecosystem file for your application, using an absolute Windows path such as D:PuppeteerTemp. Create that directory first, grant the PM2 process account write access, and reload or restart the app from the ecosystem file. Puppeteer documents this variable as the override for its temporaryDirectory configuration, which otherwise defaults to Node’s os.tmpdir().
What you need before changing the setting
- A Windows machine with Node.js, Puppeteer, and PM2 installed.
- An application started or managed from an ecosystem file.
- An absolute directory path with enough free space, for example
D:PuppeteerTemp. - Write permission for the Windows account that actually runs the PM2-managed process.
The current Puppeteer Configuration API documentation identifies version 25.12.0, while the Node OS API documentation identifies version 26.10.0. Your installed versions may differ, so check the behavior of the versions deployed in your application.
Configure PUPPETEER_TMP_DIR in the PM2 ecosystem file
1. Create the directory
Run PowerShell as an administrator only if the parent location requires elevation:
New-Item -ItemType Directory -Path 'D:PuppeteerTemp' -Force
Then check the security settings on the folder. The identity used by PM2—your interactive account, a scheduled-task account, or a Windows service account—must be able to create, modify, and remove files there. A folder that exists but is not writable will not solve temporary-file errors.
Recommended Free Tools
#1 Best Overall
- 14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
2. Add the variable to the ecosystem file
For an application whose entry point is ./app.js, create or edit ecosystem.config.js:
module.exports = {
apps: [{
name: 'worker',
script: './app.js',
env: {
PUPPETEER_TMP_DIR: 'D:\PuppeteerTemp'
}
}]
};
The doubled backslashes are JavaScript string escaping. At runtime the value is the Windows path D:PuppeteerTemp. You can use forward slashes, such as D:/PuppeteerTemp, if that is clearer in your project, but keep the value absolute.
3. Start the application from that file
pm2 start ecosystem.config.js
If the process already exists, use the ecosystem file when applying the change:
pm2 reload ecosystem.config.js
# A full restart is also valid:
pm2 restart ecosystem.config.js
Use the command appropriate for your availability requirements. Reloading attempts a rolling replacement where PM2 can do so; restarting stops and starts the process. The important point is that the application must be refreshed after the environment value changes.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallHow the setting works inside Puppeteer
PUPPETEER_TMP_DIR is Puppeteer-specific
Puppeteer’s configuration exposes a temporaryDirectory property. Its documented default is os.tmpdir(), and PUPPETEER_TMP_DIR overrides that default for Puppeteer. Putting the variable under the ecosystem file’s env object limits the setting to the PM2 application instead of changing the environment for every process on the machine.
Configuration files are another layer
Puppeteer’s guide recommends a configuration file for general default customization. That configuration layer and its environment variables are not applied by puppeteer-core. If your package is puppeteer-core rather than puppeteer, do not assume this variable will be consumed. Confirm the exact library behavior and use the relevant Node or browser launch configuration for that setup.
Rank #2
- 256 GB SSD of storage.
- Multitasking is easy with 16GB of RAM
- Equipped with a blazing fast Core i5 2.00 GHz processor.
Apply changes correctly when using PM2
Values in the ecosystem file
PM2’s ecosystem-file model injects values from the app’s env object. After editing the file, reload or restart from that file so PM2 creates a new process environment. Existing worker processes do not magically reread the JavaScript file.
Values supplied on the command line
If you set an environment value from the shell instead of editing the ecosystem file, PM2 documents the --update-env switch for restart and reload operations:
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorspm2 restart worker --update-env
pm2 reload worker --update-env
That switch is for refreshing CLI-supplied environment changes. Keeping PUPPETEER_TMP_DIR in the ecosystem file is usually easier to audit and reproduce across deployments.
Confirm which process PM2 is running
pm2 list
pm2 describe worker
pm2 logs worker
These commands help you verify the process name, script, restart state, and startup errors. They do not prove that Puppeteer selected the directory; use an explicit environment check as well.
Verify the effective Windows environment
Add a temporary diagnostic to the application, restart it, and remove the diagnostic after verification:
console.log({
PUPPETEER_TMP_DIR: process.env.PUPPETEER_TMP_DIR,
TEMP: process.env.TEMP,
TMP: process.env.TMP
});
From a separate Node process launched under the same Windows identity, you can inspect Node’s default:
Rank #3
- FULL HD IPS DISPLAY - Enjoy vibrant, crystal-clear images with 178-degree wide-viewing angles
- AMD RYZEN 3 30 PROCESSOR - Everyday performance you can count on; Multitask, stream, game casually, and edit photos smoothly with responsive power and vibrant HDR visuals
- ENJOY UP TO 14 HOURS AND 15 MINUTES OF BATTERY LIFE - HP Fast Charge restores battery from 0 to 50% in approximately 45 minutes
- AMD RADEON 610M GRAPHICS - Experience smooth entertainment; Built for streaming and multitasking, enjoy realistic visuals and efficient performance for work and play
- STORAGE AND MEMORY - 512 GB PCIe NVMe M.2 SSD offers fast speed and efficient storage; and 8 GB LPDDR5 RAM memory boosts performance with higher bandwidth
console.log(require('node:os').tmpdir());
This second value is useful for comparison. It is not a substitute for checking PUPPETEER_TMP_DIR, because Puppeteer’s dedicated override can point somewhere different from Node’s general temporary directory.
Keep temporary files, Node’s temp directory, and Chrome profiles separate
| Setting | Scope | What it selects | When to use it |
|---|---|---|---|
PUPPETEER_TMP_DIR |
Puppeteer | Puppeteer’s temporary-file directory | Use this for a Puppeteer-specific location in a PM2 app. |
TEMP or TMP |
Windows/Node process | The general temporary directory used by Node’s os.tmpdir() and other software |
Use only when you intentionally want a broader process-level change. |
userDataDir |
Chrome launch | The browser’s user-data profile, including profile state | Use this for persistent or isolated cookies, cache, extensions, and profile data. |
On Windows, Node documents that TEMP takes precedence over TMP when determining os.tmpdir(). Changing either variable therefore affects Node’s general default, not just Puppeteer. Conversely, changing PUPPETEER_TMP_DIR does not designate Chrome’s persistent profile. Puppeteer’s launch options expose userDataDir for that separate purpose.
Common failure modes and fixes
The directory is ignored
- Check spelling and capitalization of
PUPPETEER_TMP_DIR. - Ensure it is inside the app’s
envobject, not besideappsorscript. - Reload or restart after editing the ecosystem file.
- Confirm the running process sees the value with
process.env.PUPPETEER_TMP_DIR. - If using
puppeteer-core, remember that Puppeteer’s configuration files and environment variables are ignored by that package.
Access-denied or write errors
The PM2 terminal account may not be the account running the application. Check the service or scheduled-task identity and grant that identity permission on the target folder. Also verify that the drive is mounted and that antivirus or endpoint-control software is not blocking browser child processes.
Path parsing errors
Use an absolute path, escape backslashes in JavaScript, and avoid an accidental trailing quote or control character. Log the value at startup. A path such as D:PuppeteerTemp is different from a relative path whose meaning depends on PM2’s working directory.
Free tools Windows power users keep installed
One-click scans. No signup required.
Disk fills up over time
Moving the directory does not create a cleanup policy. Inspect the folder, identify which jobs leave files behind, and implement cleanup appropriate to your workload. Do not delete files while a browser process may still be using them. Keep enough free space for concurrent launches and downloads.
The browser still fails to launch
A temp-directory change cannot fix every launch problem. Check the PM2 logs, confirm the browser executable is available to the service account, verify permissions on both the temp and application directories, and test with the same account outside an interactive administrator session. Treat the documented setting as a configuration mechanism, not as a guarantee that every Windows service policy or security product will permit Chromium to run.
Rank #4
- 14” Diagonal HD BrightView WLED-Backlit (1366 x 768), Intel Graphics,
- Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD
- 3x USB Type A,1x SD Card Reader, 1x Headphone/Microphone
- 802.11a/b/g/n/ac (2x2) Wi-Fi and Bluetooth, HP Webcam with Integrated Digital Microphone
- Windows 11 OS, Dale Blue
Operational guidance for PM2 deployments
- Use one stable path per role. A worker pool can share a directory if permissions and cleanup are safe; separate directories can simplify isolation between unrelated applications.
- Provision before starting PM2. Create the directory and permissions during deployment rather than waiting for the first browser job.
- Record the effective value. A startup log line containing the selected temp path makes environment drift easier to diagnose, but avoid logging credentials or cookies.
- Plan for restarts. PM2 restarts recreate the process environment; ecosystem-file values remain the source of truth.
- Do not use the temp path for profile persistence. If a browser profile must survive restarts, configure
userDataDirseparately and protect that directory from concurrent access.
Or skip the browser setup
If your actual goal is to obtain clean website screenshots rather than run a Puppeteer browser under PM2, ScreenshotNeo provides a website screenshot API. It removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; and its MCP server lets Claude, Cursor, or another MCP client call screenshot tools.
One GET request is enough:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for the full options. You can also use the supplied Python or Node.js clients:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo supports PNG, JPEG, WebP, and PDF output, full-page and selector captures, device and viewport settings, custom CSS and JavaScript, waits, request blocking, cookies and headers, geolocation, caching, signed links, asynchronous webhooks, bulk capture, and an MCP server. Every response identifies the page verdict and whether it was billed. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
FAQ
Does this setting move files created by every Node dependency?
No. PUPPETEER_TMP_DIR is Puppeteer’s dedicated override. Other libraries may use Node’s os.tmpdir(), their own settings, or application-specific directories.
Should each PM2 instance have a different temporary directory?
Not necessarily. Sharing can work when the directory is writable and cleanup is safe. Use separate paths when isolation, quotas, or security policy requires it.
Can I change the folder without redeploying the application code?
Yes. The value lives in the PM2 ecosystem configuration, so you can edit that file and reload or restart the managed app. The new process must be created before the value takes effect.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Is a temporary directory suitable for storing downloaded business files?
No. Temporary data may be removed during cleanup or process maintenance. Store files that must be retained in an application-controlled location with an explicit retention policy.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

