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

Feature Request - Production Dependency Optimization By Running npm prune --production #2834

Open
PurnenduMIshra129th opened this issue Jan 7, 2025 · 1 comment
Labels
feature request unapproved Unapproved for Pull Request

Comments

@PurnenduMIshra129th
Copy link

Is your feature request related to a problem? Please describe.
Currently production node_moudules have dev dependency present in it . So which is not required in production. This dev dependency is only required during development of application not in production.

Describe the solution you'd like
-If we want to to reproduce this issue . Then first build the application using 'npm run build' . Then run this command npm prune --production . If we start the server using this command 'npm run prod'. Then you can see some packages that are listed under development dependency is still used in production so you will see an error the modules is not found.

-So my approch is to to compare the dependecy used in production and development enviroment then which packages are used in both production but listed under development in package.json are removed under it and add into dependecy as production.

-As a result of this only devlopment dependcy will remove by prune command . And production packages are remain unaffected.

-It will optimize our packages for production enviroment by removing unwanted nodemodules.

-Around 200-300MB of node_modules size wiil decrease which is a significant size. Which is further be helpful for our docker production image built.

Describe alternatives you've considered

  • write two script first one is for comparision between development and prodution dependcy and genrate the output in json format.
  • Save the output of this script which will furhter be used .
  • By using diff command compare both the json files and list the common depnedcy that are used in production and development .
    -Then check if the common packages are listed under development dependecy or not . If it under the dev then it should be in production dependency list.
    -Then successfully executing both the script use the command npm prune --production . Then start the server by using npm run prod. If the server start with out error like nodemodules is not found . Then it solves our problem.

Approach to be followed (optional)
N/A

Additional context
ErrorDueToDevDependencyUninstall
package json_DevDependency

Potential internship candidates

Please read this if you are planning to apply for a Palisadoes Foundation internship

@github-actions github-actions bot added the unapproved Unapproved for Pull Request label Jan 7, 2025
@PurnenduMIshra129th
Copy link
Author

PurnenduMIshra129th commented Jan 7, 2025

@palisadoes plz check this one.This is one followup for the optimization for our docker image in prodution enviroment .plz assign . I have this script and working. This is a new feature that's why i opened this issue. If u want to implement this feature in my existing pr then i will make changes docker efficiency pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request unapproved Unapproved for Pull Request
Projects
None yet
Development

No branches or pull requests

1 participant