Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Pretiier使用SyntaxError自动保存失败:意外令牌*_Javascript_Angular_Eslint_Prettier - Fatal编程技术网

Javascript Pretiier使用SyntaxError自动保存失败:意外令牌*

Javascript Pretiier使用SyntaxError自动保存失败:意外令牌*,javascript,angular,eslint,prettier,Javascript,Angular,Eslint,Prettier,我对更漂亮的配置有问题。我已经将eslint添加到项目中,以及prettier和eslint config prettier。我在WebStorm配置文件中添加了prettier作为文件观察者。但当我尝试保存文件时,prettier运行并失败,出现以下错误: /Users/anjapopovic/Projects/docker/my-app/node_modules/.bin/prettier --write src/app/app.component.ts /Users/anjapopovic

我对更漂亮的配置有问题。我已经将eslint添加到项目中,以及prettier和eslint config prettier。我在WebStorm配置文件中添加了prettier作为文件观察者。但当我尝试保存文件时,prettier运行并失败,出现以下错误:

/Users/anjapopovic/Projects/docker/my-app/node_modules/.bin/prettier --write src/app/app.component.ts
/Users/anjapopovic/Projects/docker/my-app/node_modules/prettier/bin-prettier.js:6704
  return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
                        ^
SyntaxError: Unexpected token *
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:390:7)
    at startup (bootstrap_node.js:150:9

Process finished with exit code 1
这里还有一个WebStorm prettier设置:

WebStorm编辑器中更漂亮的配置


如果有人遇到此错误,如果您能提供我一些见解,那就太好了:)

您的node版本可能太旧,无法理解求幂运算符
**
,而prettier似乎在其代码库中使用了求幂运算符。好的,Node7是第一个支持它的版本。不,我已经检查过了。我的节点版本是12.16如果你像WebStorm一样手动运行prettier会发生什么
/node\u modules/.bin/prettier
并传递相同的参数?当我运行
/node\u modules/.bin/prettier——编写src/app/home/home.page.ts
时,他会毫无问题地执行它。这是WebStorm的问题?可能是WebStorm使用了不同的(较旧的?)节点可执行文件。可能是您的节点版本太旧,无法理解求幂运算符
**
,而Pretter似乎在其代码库中使用了求幂运算符。好的,Node7是第一个支持它的版本。不,我已经检查过了。我的节点版本是12.16如果你像WebStorm一样手动运行prettier会发生什么
/node\u modules/.bin/prettier
并传递相同的参数?当我运行
/node\u modules/.bin/prettier——编写src/app/home/home.page.ts
时,他会毫无问题地执行它。这是WebStorm的一个问题?可能是WebStorm使用了不同的(较旧的?)节点可执行文件。