alexanderweiss / nova-prettier

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

Getting "Unable to start Prettier" when opening project #19

Closed trondg closed 4 years ago

trondg commented 4 years ago

When opening one specific project, I always get this error on opening the project.

This is the output from the extension console:

Vue[14:36:22.645000] Hello from Vue!

Prettier[14:36:27.729000] Using prettier from /Users/trond/websites/laravel-amorc-2/node_modules/prettier (extension located at: /Users/trond/Library/Application Support/Nova/Extensions/alexanderweiss.prettier)

Prettier[14:36:27.808000] Extension encountered an uncaught exception:
/Users/trond/websites/laravel-amorc-2/node_modules/prettier/parser-parse5.js (Line 1, Column 0)
Error: Could not find a module at path: “util”
    [native code]
    file:///Users/trond/websites/laravel-amorc-2/node_modules/prettier/parser-parse5.js:1:196
    [native code]
    map@[native code]
    file:///Users/trond/Library/Application%20Support/Nova/Extensions/alexanderweiss.prettier/Scripts/prettier.js:90:9
    asyncFunctionResume@[native code]
    [native code]
    promiseReactionJobWithoutPromise@[native code]
    promiseReactionJob@[native code]

Prettier[14:36:27.808000] Unable to set up prettier service Error: Could not find a module at path: “util” [native code]
file:///Users/trond/websites/laravel-amorc-2/node_modules/prettier/parser-parse5.js:1:196
[native code]
map@[native code]
file:///Users/trond/Library/Application%20Support/Nova/Extensions/alexanderweiss.prettier/Scripts/prettier.js:90:9
asyncFunctionResume@[native code]
[native code]
promiseReactionJobWithoutPromise@[native code]
promiseReactionJob@[native code]
alexanderweiss commented 4 years ago

What version of prettier do you have installed in this repo? It seems like the HTML parser used by prettier versions up to v1.15 doesn't work properly. Could you try updating?

trondg commented 4 years ago

This project uses version 1.14.3 of prettier, which is is required by some vue component. Updating doesn't change that. What confuses me is why the extension tries to load prettier from the project in the first place. This is a version that cannot be controlled and therefore can cause all sorts of problems.

alexanderweiss commented 4 years ago

It uses the installed version of Prettier because, like your own project, some people need a specific version of Prettier for their project. Do you think it would make sense to fall back to the built in version if there's a problem loading the one in the project?

trondg commented 4 years ago

Yes, if you are able to detect that the project version doesn't work, I think that would be a great solution.

alexanderweiss commented 4 years ago

The latest release (v1.4.0) now falls back to using the bundled Prettier. Let me know if that doesn't work for you.