Search code examples
npmterminallerna

Why Lerna creates a lot of .tgz files at root project ?


I'm using Lerna and when I use lerna publish there is a lot of .tgz files created at root of my project. How preserve theses files to be created ? thanks for any hint.

Here my project root directory:

28/09/2018 16:25 99 847 hoco_editor-alignment_plugin-1.1.0.tgz 28/09/2018 16:58 100 183 hoco_editor-alignment_plugin-1.2.0.tgz 28/09/2018 16:25
102 772 hoco_editor-bold_plugin-1.1.0.tgz 28/09/2018 16:58
102 875 hoco_editor-bold_plugin-1.2.0.tgz 28/09/2018 16:25
1 299 hoco_editor-embed_plugin-1.1.0.tgz 28/09/2018 16:58
1 507 hoco_editor-embed_plugin-1.2.0.tgz 28/09/2018 16:25
4 072 hoco_editor-font_family_plugin-1.1.0.tgz 28/09/2018 16:58
4 257 hoco_editor-font_family_plugin-1.2.0.tgz 28/09/2018 16:25
4 281 hoco_editor-font_size_plugin-1.1.0.tgz 28/09/2018 16:58
4 465 hoco_editor-font_size_plugin-1.2.0.tgz 28/09/2018 16:25
2 128 hoco_editor-image_plugin-1.1.0.tgz 28/09/2018 16:58
2 317 hoco_editor-image_plugin-1.2.0.tgz 28/09/2018 16:25
2 221 hoco_editor-italic_plugin-1.1.0.tgz 28/09/2018 16:58
2 412 hoco_editor-italic_plugin-1.2.0.tgz 28/09/2018 16:25
1 332 hoco_editor-link_plugin-1.1.0.tgz 28/09/2018 16:58
1 537 hoco_editor-link_plugin-1.2.0.tgz 28/09/2018 16:25
653 hoco_editor-list_plugin-1.1.0.tgz 28/09/2018 16:58
866 hoco_editor-list_plugin-1.2.0.tgz 28/09/2018 16:25
657 hoco_editor-toggle_readonly-1.1.0.tgz 28/09/2018 16:58
873 hoco_editor-toggle_readonly-1.2.0.tgz 28/09/2018 16:25
5 146 hoco_editor-ui-1.1.0.tgz 28/09/2018 16:58 5 332 hoco_editor-ui-1.2.0.tgz


Solution

  • I believe this happens when npm publish fails and lerna doesn't cleanup the tarballs generated by npm pack. If you drill into lerna's source, have a look at:

    https://github.com/lerna/lerna/blob/5da13190852897ac37349a28a0b24470ec7bd833/utils/npm-publish/npm-publish.js#L40

    which is basically this:

    return ChildProcessUtilities.exec(npmClient, args, opts).then(() =>
        // don't leave the generated tarball hanging around after success
        fs.remove(path.join(pkg.location, pkg.tarball.filename)).then(() => pkg)
      );
    

    so if npm (or yarn) publish fail the tarball isn't deleted.

    You can safely delete those files as they're just temporary artifacts of the publish process which shouldn't be there in the first place.