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 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

- step:
- node
- 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 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

5 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

- step:
- 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
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

126 views 2 4
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