nova-prettier
nova-prettier copied to clipboard
Not finding prettier in pnpm monorepo unless packages.json workspace config also present
This is a variation on #94, I think. Here's the setup:
- Working in a monorepo with the workspace configured in
pnpm-workspace.yaml
and not inpackage.json
-
@battis/prettier-config is installed and configured in the root
package.json
, but none of the workspace packages - The prettier module config is blank both globally and for the project
With this config, the actual prettier module is...
- Installed in pnpm's cache elsewhere on disk
- A symlink to that installation is present at
<monorepo-root>/node_modules/prettier
- No prettier module is present in any subpackage
node_modules
directory - within the repo, I can invoke prettier at the command line with
npx prettier -w <path-to-file>
I had tweaked @battis/prettier-config
to add a few more prettier plugins, and then all of a sudden things
- My initial assumption was that it was just one of the prettier plugins I had just installed, but it turned out that running prettier from the command line and through the Nova UI had different end results (and my angle brackets only disappeared in the UI) -- and the extension console confirmed that the bundled prettier was being loaded.
- When I manually set the prettier module in the extension to the path to the symlink in the root
node_modules
, the Prettier extension leaves my angle brackets unmolested -- and the extension console confirmed that the package prettier was loaded. - Operating on the theory that maybe, because neither a prettier configuration nor prettier was present in the subpackage, we were reverting to the packaged prettier instance and configuration, I installed
@battis/prettier-config
andprettier
in the subpackage. My angle brackets still disappeared -- and the extension console confirmed the bundled prettier was being loaded.
In the end, when I added my workspace configuration to the root package.json in the monorepo, the extension did identify the locally installed prettier module and prettier configuration and worked.