Open MilosMoravac opened 6 months ago
Hey @MilosMoravac , did you find any workaround for this issue ?
The original reason for this seems that the dev_dependencies should be available for the other buildpacks during build (see comment). Overwriting the user input feels wrong.
After digging a bit deeper into the code, I don't think the problem is https://github.com/paketo-buildpacks/npm-install/blob/ae1768877f1382105967b078ba99be4d90218009/build.go#L159
which will call process.Run
always with launch=false
and then https://github.com/paketo-buildpacks/npm-install/blob/ae1768877f1382105967b078ba99be4d90218009/install_build_process.go#L49 will be added.
The "problem" is that this is by intention. It will always install the dev_dependencies
for the build_modules
and use npm prune
for the launch_modules
which will remove the dev_dependencies I think.
Hey @MilosMoravac , did you find any workaround for this issue ?
So in our pipeline when we build the image using packeto we set --env NODE_ENV="production"
and that fixed it for us
@MilosMoravac Even I tried explicitly setting the NODE_ENV="production" but still during the build time it is building with NODE_ENV as "development". Could you please share the command and logs which made you get the production NODE_ENV ? We are stuck with this blocker for a really long time and would really like a solution/workaround for this.
Yeah this is biting us as well. We've had to restort to doing this in our package.json files:
{
"scripts": {
"build": "NODE_ENV=production vite build",
}
}
@MilosMoravac Even I tried explicitly setting the NODE_ENV="production" but still during the build time it is building with NODE_ENV as "development". Could you please share the command and logs which made you get the production NODE_ENV ? We are stuck with this blocker for a really long time and would really like a solution/workaround for this.
Sorry for late reply, we added --env NODE_ENV="production"
to docker run buildpacksio/pack
and it worked after that image was built.
Expected Behavior
When NODE_ENV is specified it should override development and not the other way around.
Current Behavior
Whatever is set during build environment install process it will be overridden to development
Possible Solution
Steps to Reproduce
Configuring build environment NODE_ENV -> "development" PATH -> "$PATH:/layers/paketo-buildpacks_npm-install/build-modules/node_modules/.bin"
Motivations
First of all I am a devops so this isn't really my cup of tea. So this is an issue my team has run into while using vite where the front builds and its throwing them errors. Whatever we do in nginx.toml it still uses the
NODE_ENV=development
. In the buildpack source code I found an override that always overwrites the variable you set with development I could be wrong but don't have many ideas left. I've tried locally to append env variable to 'pack build ' using--env
but it does nothing.This is the line of code I am suspecting is the issue.
layer.BuildEnv.Override("NODE_ENV", "development")
located here https://github.com/paketo-buildpacks/npm-install/blob/7b388f01af53beba6500526d3787d119610a50e5/build.go#L159