node.js - git checkout 后恢复 Angular 项目

标签 node.js angular git npm

我是 Angular 开发的新手。所以我有一个关于将存储在 Angular CLI 创建的 git 存储库中的数据的问题:实际上,我使用 ng new helloworld 创建了一个新的 Angular 工作区。使用的 Angular CLI 版本是 7.2.1。它将创建一个 Git 存储库。在 .gitignore 文件中有很多条目。迄今为止。使用 ng new 命令,它会创建一些其他重要的内容,例如 node_modules 文件夹。

现在的问题是:如果我 checkout 这个 git 存储库,我将丢失 node_modules 文件夹。这件事的方式怎么样?如何自动创建添加必要的 Node 模块?我猜这个 node_modules 文件夹的存储方式不正确,因为否则它不会是 .gitignore 文件的条目...

最佳答案

node_modules 的内容并不意味着要提交给 git。它仅包含 packages.json 文件中配置的项目包。 checkout 后,转到项目目录并运行

npm install

这将从云端下载所有必需的文件并填充新的 node_modules 目录。

关于node.js - git checkout 后恢复 Angular 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54142014/

相关文章:

java - 如何在 Eclipse Neon 中轻松地进行 Git 提交

node.js - Nodemon 在 Linux 上安装警告

node.js - Node.js 的路由引擎

xml - 如何使用带有 webpack 的 angular-cli 在 angular2 应用程序中导入 xml2js

gitlab - 使用 https 推送,指定用户名和密码

git - 是否有将在分支删除后运行的 git Hook ?

node.js - 检查 Sinon stub 方法中的第 n 次调用

javascript - typescript如何实现枚举?

angular - FormControl/FormGroup/FormArray 值类型

Angular 6 with bootstrap 4 - 表单验证电子邮件