Can't run Puppeteer within Pipelines
Asked by Kirk-Platform-FE:

My bitbucket-pipelines.yml :

```
pipelines:
default:
 - step:
name: Install Chrome
image: node:latest
caches:
 - node
script:
 - apt-get update
 - apt-get install -y wget gnupg xvfb
 - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
 - echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
 - apt-get update
 - apt-get install -y google-chrome-stable
 - ln -sf /usr/bin/google-chrome /usr/bin/chrome
 - chmod 755 /usr/bin/chrome
 - google-chrome --version
 - which google-chrome
 - node --version
 - npm --version
 - npm install
 - npm run json-web
 - cat assets/web.json
```

Puppeteer lanch code:

```
?
```

```
const browser = await puppeteer.launch({

executablePath: `/usr/bin/google-chrome`,

args: [

'--no-sandbox',

'--disable-setuid-sandbox',

'--disable-dev-shm-usage',

'--disable-accelerated-2d-canvas',

'--no-first-run',

'--no-zygote',

'--single-process', // <- this one doesn't works in Windows

'--disable-gpu'

 ],

headless: true,

// ???????

defaultViewport: {

width: 1920,

height: 1080,

 },

 });
```

When run the pipeline, error occured:  
![QQ20240715-114255@2x.png](https://community.atlassian.com/t5/image/serverpage/image-id/335520i2A3CADB7626A5B0B/image-size/large?v=v2&px=999 "QQ20240715-114255@2x.png")  
The chrome is installed successfully, but cant't find the DOM in a page.  
It works well locally.  


Answers:
author: Theodora Boudale
body: Hi [@Kirk-Platform-FE](/t5/user/viewprofilepage/user-id/5543611) and welcome to the community!

When you say it works locally, are you running this directly on your machine?

If so, your machine's environment is different from the environment where the Pipelines build runs. Pipelines builds run in Docker containers based on the image you specify in your yml file (in your case, it's node:latest).

The best way to troubleshoot a failed build in an environment similar to Pipelines, is to debug it locally with Docker by following this guide:

* <https://confluence.atlassian.com/bbkb/troubleshoot-failed-bitbucket-pipelines-locally-with-docker-1318882094.html>

I suggest following this guide and ensuring you reset the local repo to the correct commit hash (Step 2) and use the correct Docker image hash (Step 3). If possible, I also suggest following the guide on a Linux machine to rule out any issues that may have to do with different platforms.

If you follow these steps and the build still fails, it is not an issue with Pipelines and you need to debug further and figure out why the build doesn't run in this container.

If you follow our troubleshooting guide and the build succeeds, you can create a ticket with the support team and provide:

* the URL of the failed build In Pipelines
* the output of all commands when you troubleshoot the build locally as per our guide

You can create a ticket via <https://support.atlassian.com/contact/#/>, in "What can we help you with?" select "Technical issues and bugs" and then Bitbucket Cloud as product. When you are asked to provide the workspace URL, please make sure you enter the URL of the workspace that is on a paid billing plan to proceed with ticket creation.

Please feel free to reach out if you have any questions.

Kind regards,  
Theodora


author: Nicolas Grossi
body: [@Kirk-Platform-FE](/t5/user/viewprofilepage/user-id/5543611) Welcome! If you run this not in pipeline but manually it runs successfully ?

Nicolas

comments: author: Kirk-Platform-FE
body: Yes! It words well locally if I delete this line:

```
executablePath: '/usr/bin/google-chrome'
```


Tags: bitbucket-cloud

cloud