Vim-rescript error: rescript format returned an error

Recently in a project (which is a part of a monorepo) the auto-formatting has stopped working out of no where. This is only happening in one of the many packages within the monorepo.

When I run :RescriptFormat I am receiving an error:

rescript format returned an error

Is there a way to diagnose this issue?

I figured it out and it’s exactly why it felt like it “just randomly started happening”.

When working in a monorepo setup using yarn workspaces, sometimes a empty node_modules director will end up in the local package you are working on within in the monorepo and this will cause vim-rescript to search in that directory (the closest node_modules directory) which of course will be empty and not contain the rescript package and then cause operations like RescriptFormat to fail.

When working in a monorepo make sure you are launching vim from the root monorepo directory where the root node_modules directory is! I randomly started a vim session from within an individual packages directory.

Hope this helps someone in the future!

2 Likes