What are the steps to properly checkout a project that had node_modules in .gitignore? I have 2 computers. What I've been doing is
It seems to be defeating the purpose of github. So how do I avoid this weird approach? Is there an elegant way of cloning a project with missing dependencies (in this case node_modules)? I must believe there is a simple solution, but I can't seem to google the right keywords to find the solution. What keyword should I be using to find this solution?
How npm works is that there is a package.json
file that lists the npm packages and versions for the project. So when you clone the project, you get the package.json
along with the source, sans the node_modules
folder. The first step you need to do is go to a command prompt and change to the directory with package.json
. Then type in npm install
. If you have node installed correctly and added to your path, this will look at the package.json
file and download the packages from the internet, creating the node_modules
folder. You could install yarn as a replacement for npm by typing npm install -g yarn
. Then you type yarn
instead of npm install
to create the node_modules folder.
There is no need to recreate a project to create the node_modules folder, in fact that will probably cause issues because you won't have the same versions that are specified in the package.json
of the repository you cloned.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.