typescript - 使用 yarn 中的 prepare 脚本安装 npm 包只产生 index.js

标签 typescript yarnpkg

我有这个示例 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/

相关文章:

typescript - Angular2 @ TypeScript error rxjs/Subject::filtering when user stops typing

node.js - 如何将 `yarn.lock` 与 `package.json` 同步?

javascript - MongoDB - 错误 : Cannot find module '../build/Release/bson'

typescript - Angular2/Typescript - 获取服务器延迟

javascript - 如何在 yarn 中设置自定义包安装位置?

javascript - 如何为后端和前端使用一个包管理器? ( yarn /NPM)

javascript - 无法安装 create-react-app

json - 将 JSON.parse() 位置转换为行号和列

javascript - 数据未从 API [ReactJs] 加载到列表中

javascript - 如何在 Typescript 2.1+ 中使用 Bluebird