Closed dashmug closed 5 years ago
We're investigating this issue, thanks for bringing it to our attention.
@josephvusich Thanks for looking into it.
This issue should now be resolved. Let us know if you continue to experience problems.
Thank you very much.
Seems like it doesn't cache all modules for me, and npm install
requires "a peer of @babel/core@^7.0.0-0 but none is installed". Consequently, webpack build fails.
Having same issue using latest CodeBuild v2.0 image and "node 10" runtime installed. Build works fine with caching disabled.
The same with me, even tried with recursive folders.
The solution for me was to NOT use CodeBuild local caching, but instead use S3 caching mode. Not sure if this applies to your own situations, but hoping this helps someone else.
@josephvusich , still facing issues while trying to cache node_modules inside the buildspec.yml file. I am trying to use codebuild local caching and it doesn't seem to work. any suggestions??
@josephvusich , still facing issues while trying to cache node_modules inside the buildspec.yml file. I am trying to use codebuild local caching and it doesn't seem to work. any suggestions??
Hi @AditModi - just wanted to say I came here for exactly this. If you find a solution, please post here. I'll do the same.
same issue for us. Using S3 as cache. yet in the logs I can see that it fetches packages every time...
@mparent61, I've been trying the same, but have the same result as @soplan... any tips?
@joshhoegen - Not sure what you're missing, but I can just give you my basic approach in case this helps -
My aws_codebuild_project
Terraform config sets up S3 cache -
cache {
type = "S3"
location = "my-bucket-name/my-key"
}
I make sure the CodeBuild role can read/write to that bucket, and my buildspec is roughly -
version: 0.2
phases:
install:
runtime-versions:
nodejs: 14
commands:
- npm install
build:
commands:
- CI=true npm test
cache:
paths:
- node_modules/**/*
Anyone have a issue where it states "Uploading S3 cache..." and times out? I've gone over and over it and I can't figure out why it can't status an error. I've reviewed all the policy and the Source writes fine but anytime I add a cache or artifact it just hangs.
I've been trying Codebuild with both s3 and local caching since before November... Eventually, I reached out to support from a federated work account. This was the last response.
Thank for the reaching out. As per your response, I understand that you were able to successfully use caching with Github Actions which it takes less than 6 min to build while your existing CodeBuild still takes ~14min to build.
I regret the inconvenience that this may have been causing you. I have added this points to the Service Team who are currently working on your case on priority and I will soon update you with the workaround, if any.
So, now we use Github actions for testing the integrity of our builds, and allow a very slow AWS build time for env promotion.
Thanks @joshhoegen I ended up removing the ‘node_modules/*/’ and the hang time ended. I used pnpm on this project so I tweaked how that whole thing would work but still tuning. Least it finally let the lint, test jobs run built in < 6 minutes.
phases:
install:
commands:
- n 14.19.0
- echo Installing source NPM dependencies...
# This project uses angular/cli and pnpm. "aws/codebuild/standard:5.0" comes with Node 14
- npm install -g @angular/cli@13.3.6 pnpm@7.1.5
- pnpm config set store-dir .pnpm-store
- npm config -g set prefer-offline true
- npm config -g set cache /root/.npm
- npm config get cache
CodeBuild keeps its cache locally and then symlinks it to our target location as evidenced by this line:
This behaviour, however, breaks Node's module resolution causing our Node apps to fail.
This is a widely-known issue. https://github.com/npm/npm/issues/9479 https://github.com/nodejs/node-v0.x-archive/issues/25090
TLDR:
node
'srequire()
doesn't work with a symlinkednode_modules
directory if the source directory is not namednode_modules
.Because of this bug in
node
, having the following inbuildspec.yml
will fail: