Forums

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

How do I fix build error with '@sentry/react'

Alice Kim
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 4, 2022

Whenever I try to implement Pipelines, I got this error message during npm build time.

 

`Module not found: Error: Can't resolve '@sentry/react' in '/opt/atlassian/pipelines/agent/build/src'`

 

To fix this error, I put below command in bitbucket-pipelines.yml file but still build module not found error is happened.

 

```

- step:
  name: 'installing dependencies...'
  caches:
    - node
  script:
      - rm -r node_modules
      - npm install -g npm
      - npm install
- step:
  name: 'Building project'
  caches:
    - node
  script:
      - CI=false npm run build
      artifacts:
      - build/**

```

 

How can I fix this module issue during pipeline work?

Build is working well in local environment and also Jenkins environment.

1 answer

1 accepted

1 vote
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 5, 2022

Hi @Alice Kim and welcome to the community!

Which command is giving you this error? I assume it is the command CI=false npm run build ?

I see that you are installing dependencies in the previous step named 'installing dependencies...'. Are these dependencies needed in order to run the build in the next step, 'Building project'? If so, I would suggest building the project in the same step where you install the dependencies, and then checking if that eliminates the error.

For every step in your bitbucket-pipelines.yml file, a Docker container starts, your repo is cloned (unless you have disabled clone), then the commands of that step's script are executed, and afterwards the container gets destroyed. If you need any dependencies to run a build, they should be installed in the same step that uses them.

I see that you are using node cache, but please keep in mind that (1) caches are saved after the first successful build, and (2) caches are cleared automatically after 1 week and repopulated during the next successful build. Therefore, builds should be configured to work whether or not the cache is present.

Kind regards,
Theodora

Alice Kim
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 11, 2022

I don't know why it is working now but it works.

Thank you for your kindful answer. 🥲

Later if it is not working then I'll try your suggestion!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events