NPM包与控制台日志不同,缺少目录

41zrol4v  于 2024-01-08  发布在  其他
关注(0)|答案(1)|浏览(120)

我试图创建一个npm包,但结果与控制台显示的不同。
这是一个使用Vite和VueJS制作的测试库。
我有这些文件夹:.githubnode_modulessrc。它们都与package.json文件在同一个目录中。每当我运行npm run build时,它都会在根文件夹中创建一个dist目录,其中包含.js-文件。

**问题是:**每当我的GitHub-Action运行时,发布的包不包括dist目录。

由于我不希望dist目录在GitHub本身的仓库中,所以我将其添加到.gitignore。但是如果我这样做,它也不会在运行npm publish时添加到最终包中。
我还测试了创建.npmignore文件,该文件的内容与.gitignore相同,但dist条目不同。此外,我的package.jsonfiles数组中包含dist
GitHub操作输出显示了我猜正确的日志:

  1. npm notice 413B dist/components/icons/vue-theme.es17.js
  2. npm notice 787B dist/components/scaffolds/vue-theme.cjs.js
  3. npm notice 138B dist/components/scaffolds/vue-theme.cjs2.js
  4. npm notice 748B dist/components/scaffolds/vue-theme.es.js
  5. npm notice 41B dist/components/scaffolds/vue-theme.es2.js
  6. npm notice 10.9kB dist/index.css
  7. npm notice 93B dist/style.css
  8. npm notice 1.6kB dist/vue-theme.cjs.js
  9. npm notice 1.7kB dist/vue-theme.es.js
  10. npm notice 1.4kB package.json
  11. npm notice === Tarball Details ===
  12. npm notice name: @mickedplay/vue-theme
  13. npm notice version: 0.0.54
  14. npm notice filename: mickedplay-vue-theme-0.0.54.tgz
  15. npm notice package size: 7.4 kB
  16. npm notice unpacked size: 33.5 kB
  17. npm notice shasum: d8ec25fe08c650ae929702d9a5d8a4d52e866a16
  18. npm notice integrity: sha512-o2g4WiuIGhjdl[...]xn3kC5E8fKuuQ==
  19. npm notice total files: 46
  20. npm notice
  21. npm notice Publishing to https://npm.pkg.github.com with tag latest and default access
  22. + @mickedplay/[email protected]

字符串
但是每当我使用"@mickedplay/vue-theme": "github:mickedplay/vue-theme"在另一个项目中安装该软件包时,node_modules中的目录只包含两个文件:README.mdpackage.json
你可以看看测试仓库,它是公开的:https://github.com/mickedplay/vue-theme
简短总结:NPM包不包括dist目录,即使提供添加。
我做错什么了?我错过什么了吗?谢谢。

von4xj4u

von4xj4u1#

参见npm文档
您可以添加:

  1. {
  2. "files": [
  3. "README.md",
  4. "dist"
  5. ]
  6. }

字符串
package.json指定要包含的文件。

相关问题