Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,361,581
Community Members
 
Community Events
168
Community Groups

Bitbucket pipeline fails with '<package> not found' error

Hi there, I'm trying to run `eslint` and  `test` in my pipeline but they both fail with the following error:

 

+ yarn run test 

yarn run v1.22.15

$ react-scripts test

/bin/sh: 1: react-scripts: not found

error Command failed with exit code 127.

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

 

This is my ` bitbucket-pipeline.yml` file with those specific steps (here is not properly indented, but it is in my actual file)

image: node:16.13.0

pipelines:

default:

- step:

name: Installing Dependencies ?️

script:

- "yarn install"

- step:

name: Code Quality Checks ?

script:

- "yarn run lint"

- step:

name: Unit Testing ?

script:

- "yarn run test"

 

1 answer

1 accepted

0 votes
Answer accepted
Syahrul Atlassian Team Aug 17, 2022

Hey @DS 

G'day.

I believe you received the error because the image you use doesn't have react-scripts installed in it; hence the command was not found.

I found an article that explains this issue and workaround better here , which suggests you install the react-scripts as the example below in your YAML:

script:

- npm i react-scripts
- yarn run test

This should fix the issue; if not, I suggest you review and try the other suggested workaround on the page here.

Cheers,
Syahrul 

I don't suggest using both npm and yarn at the same time. It should be one or the other, not both, wherever possible.

I suggest that the issue is that bitbucket pipeline steps do not share their files. Each step runs in a separate container.

So assuming you already have the correct dependencies in package.json, the error is splitting the steps up when the files from "install dependencies" are needed in the "test" step.

I would expect a pipeline like this:

image: node:16.13.0
pipelines:
default:
- step:
name: Code Quality Checks ?
script:
- "yarn run lint"
- step:
name: Unit Testing ?
script:
- "yarn install"
- "yarn run test"

It's possible to share artifacts from one step to another, but in my experience it is simply faster to install the node_modules folder as needed in each step.
https://community.atlassian.com/t5/Bitbucket-questions/Bitbucket-pipeline-reuse-source-code-from-previous-step/qaq-p/1711660

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

3,497 views 3 10
Read article

Atlassian Community Events