alexanderweiss / nova-prettier

Prettier extension for Nova
MIT License
35 stars 6 forks source link

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

Closed davidbdyer closed 1 year ago

davidbdyer commented 2 years ago

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

dsantolo commented 2 years ago

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.

eivindml commented 2 years ago

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.

alexanderweiss commented 1 year ago

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.

davidbdyer commented 1 year ago

this was my result. "/Users/david/Sites/prayup-website-redesign/node_modules/prettier:prettier@2.8.7"

alexanderweiss commented 1 year ago

@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 commented 1 year ago

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.

davidbdyer commented 1 year ago

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
MastroPino commented 1 year ago

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 :)

alexanderweiss commented 1 year ago

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

davidbdyer commented 1 year ago

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.

alexanderweiss commented 1 year ago

Awesome! Thanks for trying out!