问题
I have a project I wrote using angular 6. I want to upload into GitHub the project but when i upload the project with GitHub Desktop, all files are uploaded except node_modules file.
When i download the project from GitHub and i try to run, because of the node_modules file is not uploaded, the project is not working. So other people can not run the project too.
if i can include the node_modules file in the GitHub Repository. it will run.
So, Why the node_modules file does not upload into GitHub ? and How can i upload this file into GitHub Repository ? Any suggestion ?
回答1:
Because a .gitignore
is generated when you generate a project, and it contains the line that excludes the node_modules
repository from being pushed.
This is done because the folder can be very heavy (several hundreds of Mb), and it would cause your pushes to be very long, and not up-to-date with your semver.
If other users want to run your project locally, they will have to run npm i
before ng serve
. That's widely accepted as a standard.
So my advice is to write a helpful README to your users to explain that, instead of pushing your node_modules folder to your repo.
回答2:
NPM designed to help developers easily find the module required and makes us focus on specific process of the app. Github knows that the required module for your app are defined in package.json.
If you want to run your code as github pages, just compile it with command ng build
. But it limited to HTML, CSS and Javascript files only. If you want people download your code, and run it by their own machine, just write a tutorial about how to getting started with your app in README.md file.
Hope this helps
来源:https://stackoverflow.com/questions/50701496/why-can-not-i-upload-the-node-modules-file-into-github-repository