作为引用,存储库是 https://github.com/microsoftly/luis-response-builder .
Node 模块文件由 tsc 生成并输出到 dist 文件夹。我有一个 prepublishOnly 步骤,删除 dist 文件夹,运行 tsc,然后针对转译的 js 运行测试。当我发布时测试就通过了。
问题是,当我在其他地方安装项目时,dist 文件夹仅包含路径为 dist/src/index.js 的文件。
我一生都无法弄清楚为什么文件在安装时丢失但在发布时丢失。
最佳答案
引用自npm-publish Documentation :
All files in the package directory are included if no local
.gitignore
or.npmignore
file exists. If both files exist and a file is ignored by.gitignore
but not by.npmignore
then it will be included.
您的存储库的 .gitignore
file包含以下内容:
node_modules
dist
*.env
yarn-error.log
由于 dist
被忽略,因此根据文档,它不会通过 npmpublish
提交。
关于node.js - npm 模块发布后丢失文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45321386/