Open sawmurai opened 3 years ago
When node_modules
gets fairly large, it's possible that rm -rf "$build_dir/node_modules/*"
gets expanded to a massive command and hits Argument list too long
errors. So, I'm not a fan of this exact solution. I think an empty node_modules
would serve the same purpose as it not existing, though.
What is driving you to mount node_modules
? Is this so you don't have to reinstall modules you've already installed locally?
Oh, I wasn't aware of the expansion problem, thanks for pointing that out. The reason we want to keep the node_modules folder is indeed that we do not want to reinstall everything. But maybe that is necessary.
If node_modules is mounted as a volume during the build process, the build process breaks because the build script is trying to remove the node_modules folder.
The responsible line is this one:
https://github.com/heroku/buildpacks-nodejs/blob/46dec4f3d9be21d320b6bb912061f1b7a0c63c05/buildpacks/yarn/bin/build#L15
Would it be possible to change that line to
rm -rf "$build_dir/node_modules/*"
or would the presence of an empty folder break succeeding code? Happy to provide a PR if that would be a feasible solution.Edit: I guess the same goes for this line:
https://github.com/heroku/buildpacks-nodejs/blob/46dec4f3d9be21d320b6bb912061f1b7a0c63c05/buildpacks/npm/bin/build#L16