Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install dev dependencies to compile project #13

Open
Arctomachine opened this issue Jun 7, 2022 · 11 comments
Open

Install dev dependencies to compile project #13

Arctomachine opened this issue Jun 7, 2022 · 11 comments
Labels
enhancement New feature or request

Comments

@Arctomachine
Copy link

Is your enhancement request related to a problem? Please describe.
Many Node dependencies, such as TypeScript, are used as dev dependencies, meaning they are required to initially compile project, but are not required later in production. This means any project that relies on TS or other libraries to compile would fail during build time.

Describe the solution you'd like

  1. Install all dependencies
  2. Build project
  3. Remove dev dependencies

Describe alternatives you've considered
Moving dependencies from dev to production list helps to solve immediate problem, but it in turn creates a problem of having dev dependencies in production, which is considered bad solution.

Additional context
image
image

@Arctomachine Arctomachine added the enhancement New feature or request label Jun 7, 2022
@rohanrajpal
Copy link

Would appreciate this as well, the official npm buildpack also has the same behavior.

12beesinatrenchcoat added a commit to 12beesinatrenchcoat/slabbot that referenced this issue Jul 17, 2022
@shadoath
Copy link

Agreed, If this were working I would continue to use it.

@hampusborgos
Copy link
Member

hampusborgos commented Aug 24, 2022

pnpm command respects the NODE_ENV environment variable to install dev dependencies (or not). Is this not sufficient?

Or you would like pnpm prune --prod executed after the build is complete?

@Arctomachine
Copy link
Author

pnpm command respects the NODE_ENV environment variable to install dev dependencies (or not). Is this not sufficient?

I provided screenshots in the post. I am not sure about how exactly this buildpack works, but it seems the way it deals with dev deps is indeed not sufficient, as you can see from logs on screenshot.

@rohanrajpal
Copy link

pnpm command respects the NODE_ENV environment variable to install dev dependencies (or not). Is this not sufficient?

Or you would like pnpm prune --prod executed after the build is complete?

So the issue is that while pnpm respects the NODE_ENV variable, its does not install the dev dependencies in the build stage, which causes the build to fail, at least for me this is the case.

@shadoath
Copy link

shadoath commented Sep 2, 2022

I would rather keep my NODE_ENV in production as I make other checks across the app with that.

Heroku has a setting for NPM_CONFIG_PRODUCTION which skips the pruning process after installing all dependencies. This to me is ideal. One check to ask if we want dev dependencies installed another to prune them or not.

@TheSecurityDev
Copy link
Contributor

I was able to fix this issue in my fork: https://github.com/TheSecurityDev/heroku-buildpack-nodejs-pnpm

Basically it overrides the NODE_ENV variable when running pnpm install so it forces it to install devDependencies, and then runs pnpm prune --prod during the prune step to remove the devDependencies after building.

@rohanrajpal
Copy link

I was able to fix this issue in my fork: https://github.com/TheSecurityDev/heroku-buildpack-nodejs-pnpm

Basically it overrides the NODE_ENV variable when running pnpm install so it forces it to install devDependencies, and then runs pnpm prune --prod during the prune step to remove the devDependencies after building.

Thanks a ton for your buildpack! Solved the only problem I had with my deployment setup.

@TheSecurityDev
Copy link
Contributor

I've created a pull request #20 to fix this issue based on my fork referenced above.

@TheSecurityDev
Copy link
Contributor

I've created a pull request #20 to fix this issue based on my fork referenced above.

Since it has finally been merged, this issue can probably be closed now.

@gamedevsam
Copy link

@hampusborgos close this plz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants