- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在为我的 Angular 应用程序使用 Angular-CLI,但由于 Angular-CLI 目前不支持用于创建库,因此我使用看似最广泛使用的 git 项目来创建我的库:https://github.com/jvandemo/generator-angular2-library
我的问题是我不想将我的 npm 模块库发布到公共(public)目录。相反,我想直接在我的依赖项中使用 git url。在开发过程中,这工作得很好。我可以在本地运行构建并在“dist”文件夹中运行 npm 链接,一切都很顺利。但是,当我将 npm 模块代码推送到 git,然后在使用项目中运行 npm install 时,我不确定如何设置它,以便我的使用项目只查看模块的 dist 文件夹并将其视为模块的根。
例如,在 node_modules/my_private_module 中,我的文件结构如下所示:
dist/
-- component1
-- compoennt2
-- my_module.metadata.json
-- my_module.d.ts
-- my_module.umd.js
-- index.d.ts
-- index.js
-- package.json
-- README.MD
package.json
README.md
我的应用程序使用的所有文件都位于/dist 文件夹中,但我不想在所有导入中指定“dist”,例如
import { myComponent1 } from 'my_private_module/dist';
我希望能够指定
import { myComponent } from 'my_private_module";
正如我在开发过程中在 dist 文件夹中运行 npm 链接时所做的那样。
有什么办法可以实现这个目标吗?
谢谢
最佳答案
在模块的 package.json 中,在根文件夹中:
typings: 'dist/index.d.ts',
main: 'dist/index.js'
删除 dist 文件夹中的 package.json。
当从 import {...} from 'my_private_module'
解析包时,模块加载器将在 node_modules< 下查找名为
,然后查找定义导出的 my_private_module
的文件夹index.js
,或者在 package.json 中查找 main
属性 - 在您的情况下,该属性也指向 index.js从 dist 文件夹中。
最好将 package.json
放在您希望找到模块的位置,并使 main
和 typings
指向索引.js 和index.d.ts。
关于node.js - 当对 npm 模块使用私有(private) git url 时,如何将使用应用程序配置为仅使用模块 dist 文件夹中的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44403561/
在基于 Dist::Zilla 的发行版中,我想要一些仅用于测试但不安装的文件。这些是运行时不需要的模型库。 我该怎么做? 最佳答案 CPAN 发行版从不安装 t 和 xt 目录。您可以将测试和模拟库
想要编写适用于多个 Linux 发行版的脚本。还想添加检查命令,如果不存在则安装一些软件包。因此,需要一个解决方案来检查 Dist 名称(如 Debian 或 RedHat)以为此 Dist 执行正确
我正在处理我的 Net::Prober分发,使用 dzil .从下一个版本开始,我想强制执行 perl 5.10+ 的最低要求(是 5.006),因为我使用的是命名捕获 :-) 现在我放了use 5.
您的文件夹的首选标记方法是什么,以区分原始 Assets 和使用任务运行器缩小、连接等的 Assets ?我见过一堆组合,最受欢迎的是src and dist , src and build , de
运行此命令后“wwwroot/dist”和“ClientApp/dist”文件夹有什么区别以及如何正确使用它们? dotnet publish -c Release 最佳答案 wwwroot/dist
我刚刚升级到 cabal 1.22.0.0。我创建了一个全新沙箱,并添加了另一个本地包的链接,如下所示: cabal sandbox add-source /home/amy/néal/créatúr
我有一个使用 Universal 的 Anugular 6 应用程序。 通用/服务器端渲染在本地工作。 我想知道如何将此应用程序部署到 azure 。考虑到它有两个 dist 文件夹(dist、dis
我已经提取了以前在另一台计算机上运行的现有 ASP.NET Core 应用程序。 当我在这台计算机上运行应用程序时,出现以下错误: AggregateException: One or more er
我试图将我的 Angular 5 代码迁移到 Angular 6。 执行 npm 后开始出现以下问题 npm start WARNING in ./node_modules/pdfjs-
/~/@ReMix-Run/Router/dist/router.cjs.js模块分析失败:/HOME/sharib/Desktop/Full Stack Developer Tutorial/MER
我正在尝试启动并运行 J2ME Polish 示例项目,但很困难。 我正在使用带有 J2ME Polish 插件的 Netbeans 8.0.2。 当我尝试创建 J2ME Polish 项目 ( Fi
Bable 只能生成 js 文件(在 dist 文件夹中),而不生成项目目录中的其他文件(如 html、css ..)。我正在使用“build”:“babel source -d dist”。 最佳答
我需要帮助,因为我在过去 2-3 天试图解决这个问题.. 我正在 Windows-7(64 位)机器上设置 Hadoop。这是为了尝试R与Hadoop的集成。 我按照 URL - http://www
我正在尝试了解gradle的分布。在7.3.3.4节 gradle documentation 中,有以下代码示例: task dist(type: Zip) { dependsOn spiJ
我想在分发期间复制一个装满 Assets 的文件夹到我的可执行文件旁边。我如何在 .cabal 文件(或者 Setup.hs)中表示它? 目录结构: root/ dist/ -- Genera
我正在构建一个自己的工具来编译相关的js文件(用ES6编写)并将其打包到一个包中。到目前为止,它与本地文件的预期一致,但是当我涉及公共(public)模块时,例如,react 和 redux 等,情况
我正在使用 gulp 为我的 Angular 应用构建分发 (dist) 文件夹。 所以我已经收集了所有 Controller /服务 JS 文件以及我的 CSS,现在我需要处理 bower 文件夹的
我有两个带有元组(坐标)的列表,例如: some_pt1 = [(10.76,2.9),(3.24,4.28),(7.98,1.98),(3.21,9.87)] some_pt2 = [(11.87,
注意 我是新手,刚刚通过编写这段代码“吹嘘”我的方式 我在用什么 - Angular(使用 Angular Cli) - 火力基地 问题/疑虑 当我运行“ng build --watch”时,它会创建
我的大多数 JavaScript 项目都有一个包含源文件的文件夹 lib 和一个包含项目构建的文件夹 dist。 我使用 WebStorm(很棒的 IDE!),并且 WebStorm 的代码检查器和代
我是一名优秀的程序员,十分优秀!