I want to pull from a private package hosted on bitbucket. Since SSH is not an option for my deploy setup, I want to access the repo using the Application Password.
So my entry in the package JSON looks like this:
"dependencies": {
"@companyName/repository": "git+https://${$BITBUCKET_USER}:${BITBUCKET_APP_PASSWORD}@bitbucket.org/company name/repository.git",
Coding username and password hard into the repo URL works fine but when I perform yarn install
as above, the environment variables are not replaced by its values.
Is there any way to use environment variables like this?
You can write a
preinstall
hook that updatespackage.json
with values from the environment. Luckily the order of lifecycle hooks work as prescribed usingyarn
.preinstall.js example:
Bonus:
How you choose to replace environment variables in
preinstall.js
is left to your good judgment. Yes, you can totally use ES6 template tags.