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,365,749
Community Members
 
Community Events
168
Community Groups

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

Atlassian Community Events