I've this simple code in index.js
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.pdf({ path: './prints/test.pdf', format: 'A4' });
await browser.close();
})();
It works with command node index.js.
BUT when I want to run it with pm2
with cmd pm2 start ecosystem.config.js --env=production
ecosystem.config.js
module.exports = {
apps: [
{
name: "print_ca",
script: "index.js",
evn: {
NODE_ENV: "development",
},
env_production: {
NODE_ENV: "production",
},
instances: 1,
exec_mode: "fork",
ignore_watch: ["node_modules", "prints", "storage"],
},
],
};
I don't know why it happens, with node index.js
it works but with PM2
won't work?