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"
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.