I'm using Yarn Workspaces in my repository and also using AWS CodeBuild to build my packages. When build starts, CodeBuild takes 60 seconds to install all packages and I'd want to avoid this time caching node_modules
folder.
When I add:
cache:
paths:
- 'node_modules/**/*'
to my buildspec
file and enable LOCAL_CUSTOM_CACHE
, I receive this error:
error An unexpected error occurred: "EEXIST: file already exists, mkdir '/codebuild/output/src637134264/src/git-codecommit.us-east-2.amazonaws.com/v1/repos/MY_REPOSITORY/node_modules/@packages/configs'".
Is there a way to remove this error configuring AWS CodeBuild or Yarn?
My buildspec file:
version: 0.2
phases:
install:
commands:
- npm install -g yarn
- git config --global credential.helper '!aws codecommit credential-helper $@'
- git config --global credential.UseHttpPath true
- yarn
pre_build:
commands:
- git rev-parse HEAD
- git pull origin master
build:
commands:
- yarn run build
- yarn run deploy
post_build:
commands:
- echo 'Finished.'
cache:
paths:
- 'node_modules/**/*'
Thank you!
Update 1:
The folder /codebuild/output/src637134264/src/git-codecommit.us-east-2.amazonaws.com/v1/repos/MY_REPOSITORY/node_modules/@packages/configs
was being attempted to be created by Yarn, with the command - yarn
at install
phase. This folder is one of my repository packages, called @packages/config
. When I run yarn
on my computer, Yarn creates folders linking my packages as described here. An example of how my node_modules
structure is on my computer:
node_modules/
|-- ...
|-- @packages/
| |-- configs/
| |-- myPackageA/
| |-- myPackageB/
|-- ...