使用 yarn 中的 prepare 脚本安装 npm 包只产生 index.js
Installing npm package with prepare script from yarn produces only index.js
我有这个带有准备脚本的示例打字稿包 运行 tsc
: https://github.com/richard-ejem/tspackage
当我使用 npm add git+https://github.com/richard-ejem/tspackage.git#master
通过 npm 安装它到一个项目时,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 中的错误?是否有一些可能的 workaround/other 方法来构建 typescript git 对纱线安装的依赖?
终于找到了解决方案 - 诀窍是将空 .npmignore
文件添加到存储库。
可能与这个问题有关:https://github.com/yarnpkg/yarn/issues/5235#issuecomment-571206092
如果没有 .npmignore
,npm/yarn 会删除安装时匹配 .gitignore
的所有内容,如果是 yarn,这会与 prepare
脚本发生冲突。 dist/index.js
没有被删除仍然很奇怪,因为它也被 .gitignore
忽略了,但是空的 .npmignore
解决了问题。
尝试通过 ssh 添加,yarn add ssh://github.com/richard-ejem/tspackage#master
不知道为什么,但它对我有用,yarn -v 1.22.15
我有这个带有准备脚本的示例打字稿包 运行 tsc
: https://github.com/richard-ejem/tspackage
当我使用 npm add git+https://github.com/richard-ejem/tspackage.git#master
通过 npm 安装它到一个项目时,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 中的错误?是否有一些可能的 workaround/other 方法来构建 typescript git 对纱线安装的依赖?
终于找到了解决方案 - 诀窍是将空 .npmignore
文件添加到存储库。
可能与这个问题有关:https://github.com/yarnpkg/yarn/issues/5235#issuecomment-571206092
如果没有 .npmignore
,npm/yarn 会删除安装时匹配 .gitignore
的所有内容,如果是 yarn,这会与 prepare
脚本发生冲突。 dist/index.js
没有被删除仍然很奇怪,因为它也被 .gitignore
忽略了,但是空的 .npmignore
解决了问题。
尝试通过 ssh 添加,yarn add ssh://github.com/richard-ejem/tspackage#master
不知道为什么,但它对我有用,yarn -v 1.22.15