Unable to run npm command in bitbucket pipeline

Viewed 1097

I'm trying to run the following pipeline in bitbucket

image: node:14-stretch

pipelines:
  default:
        - step:
            name: Install Depndencies
            caches:
              - node
            script:
                - apt update && apt install -y curl sudo git wget unzip xvfb libnss3 libgtk-3-0 libasound2 fonts-liberation
        - step:
            name: Install package.json
            script:
                - npm i
            caches:
              - node
        - step:
            name: Execute test
            caches:
              - node
            script:
                - npm run execute:test

the pipeline is failing in the last step in the script npm run execute:test, I think its caching issue but I'm not quite sure how this can be managed,down below is the error log

+ npm run execute:test
> playwright-fw@1.0.0 execute:test /opt/atlassian/pipelines/agent/build
> mocha
  Dashboard Test Suite
       browserType.launch: Failed to launch chromium because executable doesn't exist at /root/.cache/ms-playwright/chromium-888113/chrome-linux/chrome

Try re-installing playwright with "npm install playwright"

1 Answers

NPM does unfortunately not run the install scripts again when you are having cached node_modules available. Playwright uses NPM postinstall scripts for installing the browser afterwards. So you can either disable your cache there or run an additional npx playwright install which is probably the better solution for that problem.

Also instead of installing the system dependencies manually, you can use npx playwright install-deps, see here for reference.

Related