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?
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 !!!!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.