Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 ci & dependencies over SSH: build missing or scripts not being executed

We want to use Bitbucket Pipelines to test & deploy a project of ours. Two dependencies to the project are private Git repositories also on Bitbucket, formatted using the following notation in package.json:

"@namespace/repository": "bitbucket:[owner]\[repository].git#[commit-hash]"

The pipelines YML file, in a simplified form, contains the following data:

image: node:13.8.0

pipelines:
default:
- step:
caches:
- node
script:
- npm ci -dd
- find node_modules/@namespace/repository

The 'npm ci' command does succeed, but the namespace/repository's prepare script is seemingly not executed, as the 'find' script will only report the existance of the package.json and README.md file (and those are included by default).

The scripts that exist in this dependency repo:

"scripts": {
"analyze": "node ./scripts/analyze.js",
"start": "start-storybook -p 9009 -s public",
"build": "build-storybook -s public",
"build:lib": "node ./scripts/export-gen.js && webpack && node ./scripts/clean.js",
"prepare": "npm run build:lib"
}
}

The 'prepare' script (and therefore 'build:lib') makes sure that the library is built and useable as a module. Executing the same 'npm run build:lib' on (post)install collides with missing dependencies.

What are we doing wrong?

1 answer

1 accepted

3 votes
Answer accepted

We solved our issue after extensive testing, where we realised the issue was a result of the misbehaving combination of NPM and Docker.

We updated our bitbucket-pipelines.yml file to include the following line:

image: node:13.8.0

pipelines:
default:
- step:
script:
- npm config set unsafe-perm true
- npm ci -dd
- find node_modules/@namespace/repository

This relates to this issue with npm, and running 'prepare' scripts when the user is 'root' (which is the case with Docker containers). Also, running on older versions of the Node image might still yield the same failing result.

(Also, don't use the cache 'node' for 'npm ci' contexts, as it will always remove node_modules if it already exists.)

Amazing you save my day,I was trying to solve the same problem for 72 hours testing everything without any results, the funniest thing that in all local environments it worked properly

Thanks !!!!!!

Worked like a charm, saved me a few hours of head banging 👊

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,230 views 0 3
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