Module parse failed: Unexpected token

Seltzer Wang
Sep 8, 2022

在 cordova 編譯時突然出現錯誤訊息

Module parse failed: Unexpected token.
...
...
...
You may need an additional loader to handle the result of these loaders.

錯誤的地方是之前明明可以過的語法,比如

>  this.loading?.reset();
> const path = route ? The${route}Container : "TheShell";
> const route = searchParams.get("route") ?? undefined;

原因是這樣,所以要在 package.json裡面的 browserslist 部分修改

"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
"IE 11" < 加這個
],

--

--