Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

DS August 16, 2022

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
Atlassian Team members are employees working across the company in a wide variety of roles.
August 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 

Tommo
Contributor
August 18, 2022

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
AUG Leaders

Atlassian Community Events