我有这个示例 typescript 包,准备脚本运行 tsc
:https://github.com/richard-ejem/tspackage
当我使用 npm 安装它时使用 npm add git+https://github.com/richard-ejem/tspackage.git#master
到一个项目,node_modules/tspackage/dist
按预期包含 4 个文件:
- index.js
- index.d.ts
- utils.js
- utils.d.ts
但是,当使用 yarn add git+https://github.com/richard-ejem/tspackage.git#master
安装 yarn 时,dist
文件夹包含只有 index.js
。
我是不是遗漏了什么,或者这是 yarn 中的错误?是否有一些可能的解决方法/其他方法来构建 yarn install 上的 typescript git 依赖项?
最佳答案
终于找到了解决方案 - 诀窍是将空的 .npmignore
文件添加到存储库。
可能与这个问题有关:https://github.com/yarnpkg/yarn/issues/5235#issuecomment-571206092
如果没有 .npmignore
,npm/yarn 会在安装时删除所有匹配 .gitignore
的东西,如果是 yarn,这会与 prepare< 发生冲突
脚本。 dist/index.js
没有被删除仍然很奇怪,因为它也被 .gitignore
忽略了,但是空的 .npmignore
解决了问题。
关于typescript - 使用 yarn 中的 prepare 脚本安装 npm 包只产生 index.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61754026/