语法错误:意外的保留字 =>更漂亮/第三方.js



我对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

为什么会发生这种情况,我该如何确保我能在毛皮中修复它?

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

此语法:

for await (const place of this.config.searchPlaces) {
// ...
}

在NodeJS启动版本10.0.0 中可用

  1. 我第一次尝试升级节点v8-->时遇到了同样的问题节点v10运行良好。

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

降级更漂亮的版本:

npm i -D prettier@1.13.7

更多信息:https://dev.to/shivampawar/syntaxerror-unexpected-reserved-word-prettierthird-partyjs-3ph7

我在节点v8.11.2中遇到了同样的问题。将节点升级到12.3.1版本,运行良好

我知道已经晚了,但对于来这里的人来说,你可以使用node v10,也可以将更漂亮的降级到v1.x.x。

如果任何程序包抛出这样的意外错误,请检查github或node_module上的package.json,并查找引擎

"engines": {
"node": ">=8"
}, 

确保它与您的节点匹配,如果可能的话,可以更改(升级(节点版本,或者使用不同的(旧的(软件包版本。您可以通过从下拉列表中更改此文件的版本来检查哪个包版本合适。

最新更新