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

Method to skip installing Chromium #244

Closed
Garbee opened this issue Aug 11, 2017 · 23 comments
Closed

Method to skip installing Chromium #244

Garbee opened this issue Aug 11, 2017 · 23 comments

Comments

@Garbee
Copy link
Contributor

Garbee commented Aug 11, 2017

Problem

As it is, every Puppeteer install will pull its own internal Chromium copy. Whether or not it is actually used. This can end up using a lot of extra space, at 92Mb per copy currently, on peoples drives. Primarily locally where you may have multiple projects all using the tool.

Action

There should be some mechanism for skipping this download when installing dependencies if you intend to use an already existing copy of Chrome/Chromium.

@aslushnikov
Copy link
Contributor

You can install puppeteer with npm install --ignore-scripts. It also skips install scripts for puppeteer dependencies, but it works fine for now.

@Garbee
Copy link
Contributor Author

Garbee commented Aug 11, 2017

That's fine for messing with this repo itself. However, what about when people are requiring puppeteer in their projects and they have scripts they need to run after install to get things setup?

@JoelEinbinder
Copy link
Collaborator

If you try hard enough you can make it work. I don't think we should do much to encourage this. Right now Puppeteer is very tied to the version of Chromium it is bundled with. At the moment even a version from a few days earlier will be unusable.

@aslushnikov
Copy link
Contributor

@Garbee was it a problem with phantomjs-prebuilt?

There's a way we can make this work. Currently, puppeteer uses its package folder to keep chromium revision. If instead we use a shared directory, e.g. $HOME/.puppeteer-chromium-versions, we won't have any duplication.

Today's puppeteer is too young of a project, we'd rather not do this unless there are real use cases and a strong demand.

@Garbee
Copy link
Contributor Author

Garbee commented Aug 12, 2017

$HOME isn't exactly robust enough. Things may not be ran as a user with a home directory.

Ideally, I think we'd check for the environment on install. Then if a given variable exists and is the right value, don't pull the local version. Instead use the defined chromium path. Then in the system when calling chromium, you always use the path if this is set as well.

Skip download
if (process.env.PUPPETEER_PREVENT_INTERNAL_CHROMIUM === 'yes') {
  console.log('Not installing internal Chromium. Expecting binary to be located at $CHROMIUM_PATH');
  process.exit(0);
}

Nothing with phantomjs stuff. I just noticed this is going to happen on every pull. It's thinking ahead to when we release and more projects are using it, there will inevitably loads of extra disk space used.

I understand that right now it is very much a bleeding edge thing and Chromium needs to keep getting updated. But at this stage, that's also acceptable. The issue was more focusing on a long-term issue so we can start assessing proper resolution strategies.

@vsemozhetbyt
Copy link
Contributor

Maybe it is worth to use one environment variable (like PUPPETEER_EXECUTABLE_PATH) for two goals: to prevent installing Chromium and to eliminate the need of setting executablePath in the puppeteer.launch() every time?

@sukrosono
Copy link
Contributor

@vsemozhetbyt It's good idea, If PUPPETEER_EXECUTABLE_PATH is set, will use that path for launch and also skipping installing Chromium. When it's not set will Install and after it set the installation directory to PUPPETEER_EXECUTABLE_PATH.

@aslushnikov
Copy link
Contributor

@brutalcrozt there's already a way to skip Chromium download with PUPPETEER_SKIP_CHROMIUM_DOWNLOAD env variable.

@shmdhussain
Copy link

@aslushnikov what is the value for the PUPPETEER_SKIP_CHROMIUM_DOWNLOAD?

do I need to set up in PATH variable?

@ebidel
Copy link
Contributor

ebidel commented Feb 8, 2018

@shmdhussain you can set it to anything. It just needs to be defined in env. PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = true for example

@shmdhussain
Copy link

Thanks ...I updated the same as you mentioned in bash.profile...now working good without installing chromium....testing screenshot comparison of element based on the example from Monica dinculescu

@T0T4R4
Copy link

T0T4R4 commented May 2, 2018

That is what i did
echo "export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true && npm install -g puppeteer" | sudo sh

@aslushnikov
Copy link
Contributor

As of v1.7.0 the recommended way to get Puppeteer without downloading Chromium instance is puppeteer-core - see details in puppeteer vs puppeteer-core.

@CarlosEduR
Copy link

I have a question: what If my puppeteer script only works 100% on its own chromium instance? I've tried with local chrome, local chromium, but at some point, doing hard work, the script brokes, not finding some classes on page.

@albanx
Copy link

albanx commented Mar 29, 2019

Does any one knows a way to disable export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
I tried:
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=false
npm config delete PUPPETEER_SKIP_CHROMIUM_DOWNLOAD
unset PUPPETEER_SKIP_CHROMIUM_DOWNLOAD

But still npm install puppeteer will refuse to download chromium

@doenikoe
Copy link

doenikoe commented Apr 9, 2019

use unset to disable env variables. eg: unset PUPPETEER_SKIP_CHROMIUM_DOWNLOAD

@doot0
Copy link

doot0 commented Apr 15, 2019

@doenikoe - @albanx already mentioned that using unset did not work for them.

@albanx If you have a non-default shell (e.g. zsh) then try using unset after switching to bash.

@lockevn
Copy link

lockevn commented May 27, 2019

As of v1.7.0 the recommended way to get Puppeteer without downloading Chromium instance is puppeteer-core - see details in puppeteer vs puppeteer-core.

I have a helper (TypeScript) Library, which depends on puppeteer.
People using that lib can use let page = await Lib.NewPrivatePage(browser), and that browser is of type puppeteer.Browser

Is it possible to modify my Lib to work with both puppeteer.Browser and puppeteer-core.Browser? or I have to change to NewPrivatePage(browser: any)

@Garbee
Copy link
Contributor Author

Garbee commented May 27, 2019

@lockevn That's a question for whomever maintains that typescript library. It should be possible though as they'd just need to do and "or" against the types. But, afaik the typescript library isn't maintained here.

@ORESoftware
Copy link

ORESoftware commented Apr 17, 2020

can't puppeteer just be smart enough to look in node_modules/puppeteeer/chromeeeeeem and then mv the file out, not reinstall it, and then mv it back? Or something

By the time we forget to --ignore-scripts, it's already too late..puppeteer has to do this for it's users.

@leviethung2103
Copy link

The solution provided

You can install puppeteer with npm install --ignore-scripts. It also skips install scripts for puppeteer dependencies, but it works fine for now.

This solution worked for me.

@nazmulhasan21
Copy link

You can install puppeteer run this ''npm install --ignore-scripts puppeteer'' your cmd.

@hnhattien
Copy link

hnhattien commented Jul 26, 2022

Look at install.js file of puppeteer. Add PUPPETEER_SKIP_CHROMIUM_DOWNLOAD into .env will skip download Chromium

image

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