Error running savewikifolder

58 views
Skip to first unread message

Jack Baty

unread,
Dec 15, 2020, 8:59:46 AM12/15/20
to TiddlyWiki
I'm trying to convert my single-file html wiki for use via Node.js. I've typically done this using the following...

`tiddlywiki --load ./index.html --savewikifolder ./newwikifolder`

Here's what happens with the wiki I'm trying to convert...

```
node:internal/fs/utils:821
  throw new ERR_INVALID_ARG_TYPE(
  ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at Object.writeFileSync (node:fs:1512:5)
    at Object.exports.saveTiddlerToFileSync ($:/core/modules/utils/filesystem.js:337:6)
    at WikiFolderMaker.saveTiddler ($:/core/modules/commands/savewikifolder.js:165:12)
    at $:/core/modules/commands/savewikifolder.js:156:8
    at Object.$tw.utils.each (/usr/local/lib/node_modules/tiddlywiki/boot/boot.js:135:12)
    at WikiFolderMaker.saveCustomPlugin ($:/core/modules/commands/savewikifolder.js:155:12)
    at $:/core/modules/commands/savewikifolder.js:99:12
    at Object.$tw.utils.each (/usr/local/lib/node_modules/tiddlywiki/boot/boot.js:126:12)
    at WikiFolderMaker.save ($:/core/modules/commands/savewikifolder.js:79:12)
    at Command.execute ($:/core/modules/commands/savewikifolder.js:39:25) {
  code: 'ERR_INVALID_ARG_TYPE'
```

Doing this on an empty.html wiki does not throw an error. I'm not sure where to begin looking. Any tips would be appreciated. (it's the wiki at rudimentarylathe.wiki)

I'm on macOS running latest Node.js and tiddlywiki 5.1.22

Jack


Mark S.

unread,
Dec 15, 2020, 10:46:41 AM12/15/20
to TiddlyWiki
It worked fine for me, both using an early version of 5.1.23-prerelease and then with 5.1.22.
I also tried it renaming your .html to index.html and pasting your exact command. Works.

However, I'm on Linux, not Mac, so maybe there's a difference there. Also using Node v8.11.1 .

From your error, it looks like it doesn't like one of your custom plugins. Is the file at rudimentarylathe exactly the same as the one you're working with locally?

Mark S.

unread,
Dec 15, 2020, 11:00:54 AM12/15/20
to TiddlyWiki
I don't know if this is a useful clue, but you have 16 plugins in your file (besides core). But on mine only
11 plugins were generated:

codemirror-fullscreen
ContextPlugin
EditButtons
edit-comptext
notebook-mobile
relink
shiraz
shiraz_1
shuffle
Stories
uni-link


Jack Baty

unread,
Dec 15, 2020, 12:08:16 PM12/15/20
to TiddlyWiki
Thanks for testing it. I hadn't considered the mess that was my set of plugins so I removed everything not required or being used, then re-ran the command to build the node version without error!

When starting the wiki the first time I got an error about missing plugins...

> Plugins required for client-server operation ("tiddlywiki/filesystem" and "tiddlywiki/tiddlyweb") are missing from tiddlywiki.info

So I installed those, re-built the node version, and things appear to be working fine now. I wonder why I didn't see anything in docs about needing to add those plugins. Maybe I had inadvertently removed them at some point, but either way it's working now, so thanks again for setting my down the right path! 

Jack

Mark S.

unread,
Dec 15, 2020, 12:47:14 PM12/15/20
to TiddlyWiki
I'm not sure what you mean by "install". You shouldn't have to install them per se, just add the two lines:

...
        "tiddlywiki/tiddlyweb",
        "tiddlywiki/filesystem",
...

to your tiddlywiki.info file in the plugins section. It's odd that --savewikifolder doesn't insert them for you, since those will always be needed when running under node.

Joshua Fontany

unread,
Dec 15, 2020, 6:38:55 PM12/15/20
to TiddlyWiki
It's interesting. If you look at the core editions, they come in pairs, like "tw.com" and "tw.com-server".

The "-server" version has the needed plugins in the tiddlywiki.info file:
```
        "tiddlywiki/tiddlyweb",
        "tiddlywiki/filesystem",
```
and also loads the rest of the edition via an these attributes:
```
"includeWikis": [
        "../tw5.com"
    ],
    "config": {
        "default-tiddler-location": "../tw5.com/tiddlers"
    }
```

So, unpacking a single-file wiki does not include the plugins required to serve it via node.js "by default" because they do not, in fact, exist in the wiki when it is unpacked.

It's a neat way to organize things, because then you can call single-file build targets from the command line with Node & be sure the single-file Wiki generated will not error out when it is opened (as those plugins display an error if there is no backend to communicate with).

I honestly had to re-think all of my node wiki's structures when I figured this out.

Best,
Joshua F

Mark S.

unread,
Dec 15, 2020, 8:22:12 PM12/15/20
to TiddlyWiki
On Tuesday, December 15, 2020 at 3:38:55 PM UTC-8 joshua.... wrote:
So, unpacking a single-file wiki does not include the plugins required to serve it via node.js "by default" because they do not, in fact, exist in the wiki when it is unpacked.


I suspect most ordinary users were hoping to run one step and have a working node instance.  There's not even a clue in 
the documentation that the user will need to follow up by hand-editing the tiddlywiki.info file. If you're hoping to pour
your tiddlers back and forth between modes of running, this is a bit of a speed bump.
 
It's a neat way to organize things, because then you can call single-file build targets from the command line with Node &
be sure the single-file Wiki generated will not error out when it is opened (as those plugins display an error if there is no backend to communicate with).


Actually, I just tried this. Even though those two plugins shouldn't be needed to build the stand-alone file, if they are not in tiddlywiki.info
the build process will create a zero byte file. 

On the other hand, having them in the plugin section does not cause the build process to fail nor for the generated wiki to be corrupt. Nor
do the plugins appear in the plugin list. So there seems to be no harm in having them present.

So ... it seems like for most people having those two plugins automatically inserted into the tiddlywiki.info file would be advantageous 
for two different reasons. At a minimum, there should be a line or two in the --savewikifolder documentation to explain the follow-up
actions that are required. 

I guess what would be really neat would be a command option that points to a template or model tiddlywiki.info file. There are other
things missing from the tiddlywiki.info file also, such as build targets. 

Reply all
Reply to author
Forward
0 new messages