Uncaught TypeError: createRequire is not a function #725
Comments
Same thing on: Windows 10 (1909) Prettier Version 2.0.4
|
As this occurred to my newly installed system, which I installed today and it didn't happen 4 days ago, when I was using my old system, I suspect that it could have something to do with #724 Dependabot said that it had 100% compatibility, but it could be wrong there... |
Hello, It works fine with prettier 2.0.2 but not with 2.0.3 nor 2.0.4. (To test, I've reverted one by one a bunch of Dependabot PRs from the last couple of days until it worked)
|
Can confirm, I just installed the 2.0.2 version on my system and everything works as expected. |
Hopefully a patched version will be released soon. |
I can confirm also that reverting to 2.0.2 fixed the issue for me also |
While trying to find the cause, I also found these two issues |
How did you revert? I still get the error when I install 2.0.2 in my project's package.json and restart Atom. I have a .prettierrc file in my ~/Users/MyUserName folder to handle defaults |
make sure to specify the dependency without |
But just a question: why is atom-prettier getting the prettier of the project of instead getting its prettier? |
I think that is how most editor integrations work. If you have the tool installed as part of your project, it will use it. |
Thanks @BarryThePenguin for the explanation. So waiting for Prettier itself, no? |
Of course, that was it! Not the first time I have made that kind of mistake. Thank you, it now works |
Sorry about this, we use |
Prettier 2.0+ requires at least Node 10.13.0. Prettier 2.0.2 might have worked for some of you in older Node, but it was because you didn't use plugins or advanced config resolution, which use Node's new API. |
I have this problem also. Atom uses node version 10.11.0 so the only possible fix currently is to downgrade prettier to 2.0.2 |
|
Ah.. looks like Atom v1.45.0 still uses Node v10.11.0 You can check by running {
"http_parser": "2.8.0",
"node": "10.11.0",
"v8": "6.9.427.31-electron.0",
"uv": "1.23.0",
"zlib": "1.2.11",
"ares": "1.14.0",
"modules": "69",
"nghttp2": "1.33.0",
"napi": "3",
"openssl": "1.1.0",
"electron": "4.2.7",
"chrome": "69.0.3497.128",
"icu": "62.2",
"unicode": "11.0",
"cldr": "33.1",
"tz": "2019a"
} |
This can be fixed if somebody knows how we can access Node's builtin |
Access how? |
@robwise In Prettier's code. The problem is that Prettier can't access the builtin |
Prettier 2.0.5 is out. Please confirm that this issue has been fixed there. |
2.0.5 fixed the issue for me. Thanks! |
This error is still happening for me with Prettier 2.0.5, prettier-atom 0.60.0, macOS 10.15.4. |
@cravend Try |
@cravend Prettier 2.0.5 doesn't use |
Turns out I had a global install of Prettier 2.0.5, but my devDependency was locked at Prettier 2.0.4 — deleting the prettier inside of my project's Just for my reference, do projects generally include Prettier as a devDependency? |
Prettier is particularly important to install locally to ensure that the formatting by different engineers is consistent. Otherwise you’ll keep reformatting each other’s changes every time the author changes. (More broadly, I’d say absolutely everything is better installed locally) |
Exactly. For the same reason, Prettier doesn't support any kind of global configuration. We should definitely clarify this point in the docs. |
It's honestly the best way to do it and I agree. I just have a whole bunch of users who liked the ability to have it work out of the box in Atom without any configuring of their project and now I get so much blowback if I try to remove that support. |
I have resolved this issue via downgrading ESlint 6.x (not latest = 7.x). The version of the prettier package in devDependencies doesn't matter (both v2.0.2 and v2.0.5 work fine). Only for me, but might be helpful for others. |
Please close this issue as it's been fixed in Prettier 2.0.5. |
@seia-soto downgrading my global installation of ESlint from 7.0.0 worked for me too. I had tried different versions of prettier-atom, etc. |
[Enter steps to reproduce:]
1.Try to trigger prettier through save or manually
Atom: 1.45.0 x64
Electron: 4.2.7
OS: Ubuntu 19.10
Thrown From: prettier-atom package 0.58.2
Stack Trace
Uncaught TypeError: createRequire is not a function
Commands
Non-Core Packages
The text was updated successfully, but these errors were encountered: