Mbox-to-tiddlers utility

hello

Has anyone got recent experience of using Jeremy Rushton’s Mbox-to-tiddlers utility?

I am getting the following error and do not know how to solve the problem.

PS C:\Users\robjo\Desktop\mbox-to-tiddlers-master> node ./index.js ./mbox/caroy.mbox ./wiki/tiddlers/converted
C:\Users\robjo\Desktop\mbox-to-tiddlers-master\node_modules\mailsplit\lib\message-splitter.js:28
        this.errored = false;
                     ^

TypeError: Cannot set property errored of #<Readable> which has only a getter
    at new MessageSplitter (C:\Users\robjo\Desktop\mbox-to-tiddlers-master\node_modules\mailsplit\lib\message-splitter.js:28:22)
    at new MailParser (C:\Users\robjo\Desktop\mbox-to-tiddlers-master\node_modules\mailparser\lib\mail-parser.js:132:25)
    at module.exports (C:\Users\robjo\Desktop\mbox-to-tiddlers-master\node_modules\mailparser\lib\simple-parser.js:25:18)
    at Mbox.<anonymous> (C:\Users\robjo\Desktop\mbox-to-tiddlers-master\index.js:25:2)
    at Mbox.emit (node:events:513:28)
    at emit (C:\Users\robjo\Desktop\mbox-to-tiddlers-master\node_modules\node-mbox\src\mbox.js:53:12)
    at DestroyableTransform.<anonymous> (C:\Users\robjo\Desktop\mbox-to-tiddlers-master\node_modules\node-mbox\src\mbox.js:97:11)
    at DestroyableTransform.emit (node:events:513:28)
    at addChunk (C:\Users\robjo\Desktop\mbox-to-tiddlers-master\node_modules\readable-stream\lib\_stream_readable.js:291:12)
    at readableAddChunk (C:\Users\robjo\Desktop\mbox-to-tiddlers-master\node_modules\readable-stream\lib\_stream_readable.js:278:11)

Node.js v18.16.1
PS C:\Users\robjo\Desktop\mbox-to-tiddlers-master>

Any help would be much appreciated

Do you have a link to the tool?

Hi @Rob_Jopling I suspect that this is because the utility was written for a much older version of Node.js than the one you are probably using. The dependencies probably need to be updated. I will investigate as soon as I can.

@pmario this tool is something I wrote a few years ago and is published at GitHub - Jermolene/mbox-to-tiddlers: A utility to convert mbox files into tiddlers

Hi @Rob_Jopling I can confirm that this is indeed a Node.js compatibility problem. mbox-to-tiddlers still works under Node.js 16.x, but 18.x and later versions raise the error you note.

The error is raised within the “mailsplit” library. I updated to the latest version but the problem is not fixed, so I suspect that the solution might be switching to a different library.

You may be able to use nvm to temporarily install Node.js 16.x just to run mbox-to-tiddlers - see GitHub - nvm-sh/nvm: Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

1 Like

Many thanks @jeremyruston for investigating this and for suggesting a workaround.

Also, apologies for misspelling your surname!

Hello @jeremyruston. Digging into the dependency resolution a bit, it looks like an old version of mailsplit is being pulled in as a dependency of mailparser, which specifies exact versions for its dependencies. Updating the minimum version of mailparser to 3.5.0 should pull a fixed version of mailsplit, but that involves a major version change for mailparser.

I’ve done a small bit of testing with this on Node 22 and it appears to work mostly the same, although there are a few small differences in the output compared to using the unmodified version of your script on Node 16.

Hi. How would I go about updating Mailparser? I have very little experience of working at the Terminal level !! Cheers.

In the directory where you downloaded the mbox-to-tiddlers code, there is a file called “package.json”. You don’t need to worry about most of what’s in there, but the relevant part looks like this:

  "dependencies": {
    "mailparser": "^2.7.5",
    "node-mbox": "^1.0.0",
    "tiddlywiki": "^5.1.21"
  },

On the line that starts with “mailparser”, change the version number like so:

  "dependencies": {
    "mailparser": "^3.5.0",
    "node-mbox": "^1.0.0",
    "tiddlywiki": "^5.1.21"
  },

Then run “npm install” again. This should pull the latest version of mailparser 3.x that is greater than 3.5.0 (when the patch was introduced for Node 18 and later).

As I said above, I’ve only done some limited testing and there are some differences in the output versus when I ran the script using the old mailparser and Node 16. This also isn’t a tool I’ve used before now, so I can’t say for certain that the output is working 100% correctly after making this change.

If it works well for you, I’d appreciate knowing it did so.

One note of warning: I did see some messages in my mbox files weren’t being read correctly by the “node-mbox” package, resulting in “mailparser” receiving partial messages (eg: no subject or date). This was happening with the original version on Node 16 as well, so I think it’s something about how Thunderbird is storing the messages in the mbox file and not related to these package dependencies.

Many thanks. I’ll give that a go and I’ll get back to you. Cheers

That worked with no errors. And importing the resulting tiddlers into a tiddlywiki appears to have worked as it should do.

All I need to do now is to rename the tiddlers using the value in the caption field; the message id is actually not a very useful title for the tiddler!!

For your information, the mbox file i used was one generated by Google as a takeout from my Gmail account.

Thanks again for your assistance.