Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

npm install not working with Bitbucket runner

Ajay _view26_ Community Leader Nov 30, 2021

I get the below error when using runner for the below pipeline. Is it because I am not using a custom docker image to run node?

 

pipelines:
  branches:
    develop:
      - step:
          runs-on: self.hosted
          name: Build the package
          script:
            - cd frontend
            - npm install
            - npm run build
            -
          artifacts:
            - build/**

Screenshot 2021-11-30 211610.png

1 answer

1 vote
Norbert C Atlassian Team Dec 03, 2021

Hi Ajay,

Thank you for contacting Atlassian Community! I'm Norbert from Bitbucket Cloud Support, it's nice to meet you! 

Based on my observation your build fails as the NPM is not able to authenticate with the remote repository. 

Based on the following link, removing the ".npmrc" resolves this issue: https://stackoverflow.com/questions/48823562/npm-install-resulting-in-401-unauthorized-for-private-repo

Can I ask you to try to remove this file and let us know if it resolves the issue?

I'm looking forward to hear from you, Ajay.

Best Regards,
Norbert
Atlassian Bitbucket Cloud Support

Ajay _view26_ Community Leader Dec 05, 2021

Hi @Norbert C 

Thanks for the reply.

As it tuned out I was using private modules in my package.json and therefore the 401. I followed the documentation mentioned here to configure the  .npmrc file and it works fine.


If you are using private modules from either the public npm registry or your own private registry you can simply check in a .npmrc file at the root of your repository using repository variables. To avoid conflict with the local ~/.npmrc file during development you can simply name it .npmrc_config and rename it as part of the pipeline script.

.npmrc_config

//registry.npmjs.org/:_authToken=${NPM_TOKEN}
registry=https://registry.npmjs.org

& in the Pipeline 

pipelines:
default:
- step:
script:
- mv .npmrc_config .npmrc
- npm install

 


Cheers

Ajay

Norbert C Atlassian Team Dec 06, 2021

Hi Ajay,

Thank you for your reply. We appreciate your detailed explanation and we're glad to hear that it works :).

Have a great week ahead!

Best Regards,
Norbert
Atlassian Bitbucket Cloud Support

Suggest an answer

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

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,487 views 4 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you