如何解决语法错误:意外的保留字=>更漂亮/third-party.js
我对Node,npm和webpack很陌生。我正在尝试使用Tailwind CSS设置Craft 3 environment。
一切正常可用,但是当我运行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) {
// ...
}
可从版本10.0.0开始的NodeJS中获得
,-
我首先遇到了相同的问题,尝试升级 node v8 -> node v10 效果很好。
-
如果您不想升级节点版本,可以将更漂亮的版本降级为 prettier@1.13.7 。此修复程序也可以正常运行。 >
降级更漂亮的版本:
npm i -D prettier@1.13.7
,
我在节点v8.11.2中有相同的问题。将节点升级到版本12.3.1,并且工作正常
,我知道已经晚了,但是对于来这里的人,您可以使用 node v10 或将 prettier 降级到 v1.x.x。
如果任何包抛出了这样的意外错误,请在 github 或 node_module 上检查它的 package.json 并查找 engines
"engines": {
"node": ">=8"
},
确保它与您的节点匹配,如果可能,请更改(升级)节点版本或使用其他(较旧的)软件包版本。您可以通过更改此文件的下拉列表中的版本来检查哪个包版本适合。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。