alexanderweiss / nova-prettier

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

error on save #24

Closed bugcafe closed 4 years ago

bugcafe commented 4 years ago

Hi,

I get the following error when saving a file with prettier 1.5.2 installed.

TypeError: locEnd is not a function TypeError: locEnd is not a function at isNextLineEmpty (/Users/bugcafe/node_modules/prettier/index.js:12195:42) at /Users/bugcafe/node_modules/@prettier/plugin-php/src/printer.js:620:16 at FastPath.map (/Users/bugcafe/node_modules/prettier/index.js:14390:21) at printArgumentsList (/Users/bugcafe/node_modules/@prettier/plugin-php/src/printer.js:614:33) at printNode (/Users/bugcafe/node_modules/@prettier/plugin-php/src/printer.js:2112:9) at Object.genericPrint [as print] (/Users/bugcafe/node_modules/@prettier/plugin-php/src/printer.js:116:32) at callPluginPrintFunction (/Users/bugcafe/node_modules/prettier/index.js:14581:18) at /Users/bugcafe/node_modules/prettier/index.js:14531:47 at Object.printComments (/Users/bugcafe/node_modules/prettier/index.js:14204:19) at printGenerically (/Users/bugcafe/node_modules/prettier/index.js:14531:22)

alexanderweiss commented 4 years ago

It's a problem with Prettier and the PHP plugin due to incompatibilities between versions: https://github.com/prettier/plugin-php/issues/1352 and https://github.com/prettier/plugin-php/issues/1492. What version of both do you have installed in your home folder? Also, does/did this problem not occur when using the version downloaded through the extension library (they both show as 1.5.2)? It shouldn't make a difference really.

bugcafe commented 4 years ago

With extension version 1.5.2, Is it a requirement that I have prettier and prettier PHP plugin installed manually? So for the purposes of testing , I don't have prettier manually installed. I have not installed Prettier in the home folder, which made me wonder why it was looking there for Prettier? In order for the extension to work, is it a requirement that prettier and any plugin manually installed in the home folder?, or should the Nova Extension be handling that?

alexanderweiss commented 4 years ago

Do you mean the actual 1.5.2 downloaded through the extension library? Or the one downloaded from Github? (they show the same version)

In the one from Github It's no longer required to install Prettier and the PHP plugin for it to work with PHP. In both versions it will try to use the Prettier installed in your project though. It uses npm ls for that. So unless you have your home folder open in Nova, it won't find Prettier there.

So what directory do you have open in Nova? And what else does the extension console say? It should say Loading bundled prettier at... and Starting.... It would be helpful to know what that output says exactly. And looking at the error it does seem like you have prettier and @pretier/plugin-php installed in your home folder as well.

bugcafe commented 4 years ago

ok i think i have it working now, there was some remnants of prettier in the home folder, didnt realize they were there and that was causing the issue, deleted and installed latest prettier and php plugin does work, also works with prettier not installed there and using the internal version supplied by the nova extension. thanks for your time!

alexanderweiss commented 4 years ago

Awesome! Let me know if you run into anything else. I'll probably release this version as 1.6.0 in a few days.