Search code examples
aws-code-deployaws-codepipelineaws-codebuildlernaaws-code-deploy-appspec

Lerna on AWS CodeBuild & CodeDeploy Not Installing Local Dependencies


So I have a Typescript project called backend with a depedency like such in its package.json:

"dependencies": {
  "@the-couple-game/helpers": "^1.0.0",
}

And helpers (also Typescript) is in another folder with its package.json like such:

{
    "name": "@the-couple-game/helpers",
}

So running lerna bootstrap should link the two and install @the-couple-game/helpers in backend's node_modules which it does locally.

However, doing the same (with --no-ci because I don't want npm ci) using Codebuild using the below buildspec.yml does not add a @the-couple-game/helpers in backend's node_modules. So if I run backend's transpiled index.js it would complain about the missing module.

version: 0.1
phases:
  install:
    commands:
      - npm install -g lerna
  pre_build:
    commands:
      - lerna bootstrap --no-ci --concurrency 4
  build:
    commands:
      - lerna run build --concurrency 4
artifacts:
  files:
    - "**/*"

For now, I have to resort to manually doing a lerna bootstrap after deployment to CodeDeploy (using a script called from appspec.yml) so it installs the missing module but shouldn't Codebuild have covered that part?

Thanks.


Solution

  • So it turns out AWS CodePipeline doesn't support symlinks in source (Codebuild in my case). Reference

    So after deployment, I'll have to lerna link using a shell script to create the links which is not an expensive job for my micro ec2 instance to do.