Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 898
Ramon Avatar asked Aug 28 '20 14:08

Ramon


2 Answers

  1. I faced same issue first I tried with upgrading node v8 --> node v10 works fine.

  2. 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://devsnooper.com/syntaxerror-unexpected-reserved-word/

like image 87
Shivam Pawar Avatar answered Sep 23 '22 06:09

Shivam Pawar


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

like image 27
Ki Jéy Avatar answered Sep 22 '22 06:09

Ki Jéy