nova-prettier icon indicating copy to clipboard operation
nova-prettier copied to clipboard

The Plugin doesn't automatically find the prettier module in node_modules.

Open davidbdyer opened this issue 3 years ago • 2 comments
trafficstars

The Plugin doesn't automatically find the prettier module in node_modules in my project folder. VSCode doesn't have a problem doing so.

davidbdyer avatar Feb 24 '22 00:02 davidbdyer

Think I am also facing this issue.

If I configure prettier using some package that installs it as a dependency (and puts it in node_modules), this extension ignores it.

I'm even pretty sure that if I directly configure prettier in package.json file the extension also ignores it. Seemingly the only way to configure Prettier with this extension is through the extension preferences.

dsantolo avatar Apr 04 '22 01:04 dsantolo

Yes, I'm getting different formatting results from using the plugin, compared to running yarn prettier --write .. Looks like it's not using the config, and/or the correct prettier version located in node_modules/.bin/prettier.

eivindml avatar Apr 27 '22 06:04 eivindml

Could you run npm ls prettier --parseable --long --depth 0 in your project folder and share the result? The extension tries to find Prettier through this npm command.

alexanderweiss avatar Apr 02 '23 15:04 alexanderweiss

this was my result. "/Users/david/Sites/prayup-website-redesign/node_modules/prettier:[email protected]"

davidbdyer avatar Apr 03 '23 02:04 davidbdyer

@davidbdyer thanks! That looks like it should be using your project prettier then. Just checking, but I assume you use npm? Can you take a look at what the extension console outputs? It's under Extensions -> Extension Console (after you've enabled Extension Development in Preferences). It should show Loading project prettier at ... and then Loading prettier at .... That path should be the same as the one you posted. Is it and / or is there any additional logs?

alexanderweiss avatar Apr 10 '23 12:04 alexanderweiss

I've changed the way the extension finds your Prettier installation to not use npm but just traverse the filesystem instead. I'd be curious to hear if that solves your issue. I've created a pre-release for the latest changes: https://github.com/alexanderweiss/nova-prettier/releases/download/v2.5.0/prettier.novaextension.zip.

It doesn't currently support global installations. But it didn't before either.

alexanderweiss avatar Apr 10 '23 15:04 alexanderweiss

I'm using npm. I started using a global npm install of prettier on my more recent projects. The path displayed in the console reflects that. Currently Prettier is working with the global and local installs, including prettier plugins. It is also seems to be reading my .prettierrc file. It often requires a Nova restart if i make any changes. When I use the global install I just add the global path to the preferences. /usr/local/lib/node_modules/prettier I haven't tried the v2.5.0 prerelease version yet.

These are the paths from the console. They appear to be the same as the one I posted earlier.

Prettier[14:04:44.780000] Loading project prettier at /Users/david/Sites/prayup-website-redesign/node_modules/prettier
Prettier[14:04:44.780000] Loading prettier at /Users/david/Sites/prayup-website-redesign/node_modules/prettier

davidbdyer avatar Apr 11 '23 18:04 davidbdyer

Hi there, this pre release version fix the problem that the plugin doesn't automatically find the prettier module in node_modules in my project folder (Nova feedback). All work as expected, thanks :)

MastroPino avatar Apr 13 '23 10:04 MastroPino

@davidbdyer what's your problem exactly then? It's indeed using your project's prettier installation.

alexanderweiss avatar Apr 16 '23 10:04 alexanderweiss

Everything seems to be working now. I can't remember what the issue was back in February. I think it wasn't using the prettier plugins like prettier-plugin-css-order and prettier-plugin-sql.

davidbdyer avatar Apr 16 '23 16:04 davidbdyer

Awesome! Thanks for trying out!

alexanderweiss avatar Apr 16 '23 18:04 alexanderweiss