javascript - 用于发布的 Angular 节点模块的版本控制
问题描述
在尝试在 npm 上发布 Angular 组件时,我不太确定哪些文件夹和文件应该包含在版本控制过程中,哪些应该包含在.gitignore
.
我使用 Angular CLI 进行发布。主要代码在其中,为了进行转译,我使用项目文件夹内的./projects/nls-ngx-module/src/**
本机 angular 命令。ng build --prod
在dist/
一个带有项目标题的新文件夹中。美好的。
转译后,node_modules
项目文件夹中又增加了一个文件夹,默认不忽略。它只包含一个.cache
带有子文件夹和文件的文件夹。这让我很恼火,因为在其他示例项目中它们没有出现,但它们也没有被手动忽略.gitignore
。
文件夹结构
├── ...
├── projects
│ └── nls-ngx-module
│ ├── karma.conf.js
│ ├── ng-package.json
│ ├── ng-package.prod.json
│ ├── package.json
│ ├── src
│ │ ├── lib
│ │ │ ├── ...
│ │ ├── public_api.ts
│ │ └── test.ts
│ ├── tsconfig.lib.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── src
│ ├── app
│ │ ├── ...
│ ├── assets
│ ├── browserslist
│ ├── environments
│ │ ├── ...
│ ├── ...
├── ...
.gitignore
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
package-lock.json
# System Files
.DS_Store
Thumbs.db
示例取自:
解决方案
不,不必修改.gitignore
文件。该ng build
命令在错误的目录中执行。
不要在应用程序的根目录之外ng build --prod
运行或任何类似的ng build
命令。只有在项目目录的子文件夹中运行命令时,才会在项目目录中创建node_modules文件夹。ng build
注意
该ng build
命令分发package.json
. 因此,必须有一个node_modules文件夹才能正确捆绑构建的库。
推荐阅读
- javascript - 如何在 angular 项目中的 tensorflow.js 中上传 csv 文件?
- snipcart - Snipcart 或其他类似解决方案
- java - 我的 editor_layout_problem - 2 如何在 scoll 或 listview 中多次显示不同的片段
- java - Android RecyclerView 仅在关闭并重新启动应用后显示项目
- angular - 如何在 Spring MVC 中为 Angular 前端生成下载文件弹出窗口?
- r - 带假人的非线性最小二乘法
- mysql - MySQL Multiple INNER JOIN + GROUP BY 未按预期工作
- javascript - 如何更改 vuetify 数据表中单个按钮的属性?
- android - 有什么方法可以捕捉电话接听事件吗?
- javascript - 是什么导致我的代码中出现“RangeError:超出最大调用堆栈大小”?