New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't resolve 'module' in '...../node_modules/prettier' #4879
Comments
Hello @swufexim! Would it be possible for you to provide a small example that reproduces the problem? |
This looks like a
I guess this issue should probably be fixed either in |
Thanks for your reply. Hello @j-f1 Hello @ikatyang
I think this may be caused by the setting of webpack config:
because I will run my project in the browser. Now, I use prettier with |
Has this been fixed? or is there some recommended work around? I am trying to use it in electron with webpack and it keeps blowing up with same error :( |
FYI, we updated |
@grofit you can either do this, to force using electron's
Or you can require "prettier/standalone" instead of "prettier". |
@grofit Now in my project, I use const prettier = require("prettier/standalone");
const prettierBabylon = require("prettier/parser-babylon");
const prettierTS = require("prettier/parser-typescript");
const content1 = prettier.format("some typescript codes", {
parser: "typescript",
plugins: [prettierTS]
});
const content2 = prettier.format("some json texts", {
parser: "json",
plugins: [prettierBabylon]
}); |
ok thanks guys will give them a try. UpdateStill didnt work trying the above (tried eval and normal require) also tried adding externals in webpack config. One thing that I am doing which is possibly not normal is specifying the webpack target as "web" as I am running electron from a web server in a dev version. Anyway if this is potentially fixed in the new version I will just wait for that. |
Any news on this one? I am trying to use the csharp plugin and trying @swufexlm approach looks sensible but just blows up for me, and the plugin docs imply you should provide a path (ideally want to bundle it in with the electron stuff so it doesnt need to lookup at runtime, so the passing of the plugin object seems a nicer approach). Any info would be great! |
Environments:
Steps to reproduce:
I have a project base on create-react-app, typescript@2.9.2 and wepack@3.8.1. When I try to add prettier to my project, the webpack has a compile error:
But I can find the 'module' declare in @types/node/index.d.ts:
What can I do to solve this problem?
The text was updated successfully, but these errors were encountered: