SyntaxError:意外的保留字 => prettier/third-party.js

Ram*_*mon 13 node.js npm gulp webpack prettier

我对 Node、npm 和 webpack 还很陌生。我正在尝试使用 Tailwind css设置Craft 3 环境

开箱即用,一切正常,但是当我运行时npm run dev,出现以下错误:

> craftcms-tailwind@1.0.0 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! craftcms-tailwind@1.0.0 dev: `gulp dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the craftcms-tailwind@1.0.0 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
Run Code Online (Sandbox Code Playgroud)

为什么会出现这种情况,我如何确保我可以在 Furure 中解决这个问题?

Ki *_*Jéy 9

如此处所述:https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of

此语法:

for await (const place of this.config.searchPlaces) {
  // ...
}
Run Code Online (Sandbox Code Playgroud)

在 NodeJS 版本 10.0.0 中可用


Shi*_*war 6

  1. 我首先遇到了同样的问题,我尝试升级节点 v8 -->节点 v10工作正常。

  2. 如果您不想升级您的节点版本,您可以将 prettier 版本降级到prettier@1.13.7此修复程序也正常工作。

降级更漂亮的版本:

npm i -D prettier@1.13.7
Run Code Online (Sandbox Code Playgroud)

更多信息:https : //devsnooper.com/syntaxerror-unexpected-reserved-word/