Managing node_modules between projects? #450
-
Hi, I am new to the javascript environment, and just got started with the Lesson 6: Hardhat Simple Storage section. I googled and looked into pnpm, which creates softlinks of existing modules so node_modules folder remains light when shared between projects, but i cannot mix yarn with pnpm or it can lead to lock issues. Whats the best practice in maintaining node_modules in javascript development? I dont want to create 10 smart contract projects and have 2GB of my disk space on node_modules alone, which are also the same between all the projects? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@aranyadan One solution is that you can install packages globally so that you will not be required to install them for every project. But I think this approach is not good, because each project has its own dependencies that are only required for that particular project, and installing it globally will take space forever. We do install packages globally like npm, but only those packages that we mostly use in every project. And the second solution is that you can remove these node_modules folders from projects that you are no longer working on and when you start working on that project again you can install it with the command This is the approach that everyone follows, I do not know if you have noticed or not that we include the node_module folder inside the git ignore file so we should not upload it on Github, because we and other people who will fork/clone our project do not need that. Just when you download the code locally we can get all of the dependencies of the project with the above command. hope it clears your query. |
Beta Was this translation helpful? Give feedback.
@aranyadan One solution is that you can install packages globally so that you will not be required to install them for every project. But I think this approach is not good, because each project has its own dependencies that are only required for that particular project, and installing it globally will take space forever. We do install packages globally like npm, but only those packages that we mostly use in every project.
And the second solution is that you can remove these node_modules folders from projects that you are no longer working on and when you start working on that project again you can install it with the command
npm install
and all dependencies will come again.This is the ap…