Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Puppeteer updated caching directory #133

Open
isabella-projects opened this issue Jan 13, 2025 · 3 comments
Open

Puppeteer updated caching directory #133

isabella-projects opened this issue Jan 13, 2025 · 3 comments

Comments

@isabella-projects
Copy link

isabella-projects commented Jan 13, 2025

What version of pkg are you using?

6.2.0

What version of Node.js are you using?

locally latest, but specified node20-win-x64 when running pkg cmd

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?

node20

Describe the Bug

When trying to build an application which has puppeteer 24.0.0 , it always throws the warning:

Warning Cannot include directory %1 into executable.
The directory must be distributed with executable as %2.
%1: node_modules\puppeteer.local-chromium
%2: path-to-executable/puppeteer
Warning Babel parse has failed: Unexpected token, expected "from" (1:12)
Warning Failed to make bytecode node20-x64 for file C:\snapshot\my_app\node_modules\typed-query-selector\shim.d.ts

I already tried copying the the .cache directory from %HOME%/.cache , where is the chrome.exe to the root of my project. Also by following the steps from: https://pptr.dev/guides/configuration#changing-the-default-cache-directory didn't do the trick.
Nevertheless the puppeteer package also uses ES6 inside typed-query-selector, which causes the warnings after the first one.

Expected Behavior

Should locate the executable from the .cache folder in your root project directory when specified in the .puppeterrc.js:

const {join} = require('path');

/**
 * @type {import("puppeteer").Configuration}
 */
module.exports = {
  // Changes the cache location for Puppeteer.
  cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
};

To Reproduce

  1. Install latest Puppeteer version
  2. Run pkg app.js -t node20-win-x64
  3. Warnings occur, even though the application is running properly
@robertsLando
Copy link
Member

this is expected, did you added it to assets ?

@isabella-projects
Copy link
Author

isabella-projects commented Jan 14, 2025

Yes, I have this in package.json

	"pkg": {
		"scripts": [
			"index.js"
		],
		"targets": [
			"node20-x64"
		],
		"assets": [
			".cache/puppeteer/chrome-headless-shell/**/*",
			".cache/puppeteer/chrome/**/*"
		]
	},

Am I mistaken or it is not possible to bundle the headless browser at all?

@robertsLando
Copy link
Member

In that case you should do this in a different way. When running in a pkg executable (process.pkg is not undefined) you should add a step that reads the exe from snapshot and copies it to a local directory. See the example for FFmpeg:

https://github.com/yao-pkg/pkg?tab=readme-ov-file#error-cannot-execute-binaray-from-snapshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants