node.js - npm 模块发布后丢失文件

标签 node.js typescript npm node-modules npm-publish

作为引用,存储库是 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/

相关文章:

typescript - 观察 Polymer 中的数组元素不适用于 bool 绑定(bind)

javascript - 使用带有 <input> 标签的 Angular 进行多选下拉菜单

node.js - npm install --save,不保存有什么用

node.js - Scala.js - 从 SBT 运行传递命令行参数

node.js - Box 或 Google Drive 作为 Nodejs Web 应用程序的存储

visual-studio - Web Essentials 不显示 typescript 预览

client - Meteor Npm-module 客户端?

node.js - 在 Windows 10 上安装 Node.js(和 npm)

css - 将 .css 文件添加到 ejs

javascript - 如何在 Node.js 中使用带有 Promise 的 MongoDB?