'SyntaxError: Unexpected reserved word => prettier/third-party.js
I'm pretty new to Node, npm and webpack. I'm trying to set up a Craft 3 environment with Tailwind css.
Everything worked fine out of the box, but when i run npm run dev
i get the following error:
> [email protected] dev /Users//sites/***/www
> gulp dev
/Users/***/sites/***/www/node_modules/prettier/third-party.js:9871
for await (const place of this.config.searchPlaces) {
^^^^^
SyntaxError: Unexpected reserved word
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/***/sites/***/www/node_modules/prettier/index.js:16551:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `gulp dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/***/.npm/_logs/2020-08-28T14_23_16_034Z-debug.log
Why is this hapening and how can i make sure i can fix this in the furure?
Solution 1:[1]
As described here : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of
This syntax :
for await (const place of this.config.searchPlaces) {
// ...
}
is available in NodeJS starting version 10.0.0
Solution 2:[2]
I faced same issue first I tried with upgrading node v8 --> node v10 works fine.
If you do not want to upgrade your node version you can downgrade prettier version to [email protected] This fix is also working properly.
Downgrade prettier version:
npm i -D [email protected]
More info: https://dev.to/shivampawar/syntaxerror-unexpected-reserved-word-prettierthird-partyjs-3ph7
Solution 3:[3]
I had the same issue in node v8.11.2. Upgraded node to version 12.3.1 and it works fine
Solution 4:[4]
I know it's late but for people coming here, you can either use node v10 or downgrade prettier to v1.x.x.
If any package throws an unexpected error like this please check it's package.json on github or from node_module and look for engines
"engines": {
"node": ">=8"
},
make sure it matches your node, either change (upgrade) the node version if possible or use a different (older) package version. You can check which package version is suitable by changing the version from dropdown for this file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ki Jéy |
Solution 2 | |
Solution 3 | Tabrez Basha |
Solution 4 | mukuljainx |