You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用create-react-app构建后执行serve -s build报async语法错误求助

Fixing "SyntaxError: Unexpected identifier" When Running serve -s build

The error you're hitting stems from an outdated Node.js version that doesn't support the async/await syntax natively. Async/await is an ES2017 feature introduced in Node.js 7.6.0—your current Node version is too old to parse this syntax, which is why the serve tool (which uses async/await in its code) is throwing an error, even though your React app was correctly transpiled by create-react-app.

Here are two reliable fixes:

Older Node.js versions are no longer maintained and pose security risks, so upgrading is the best long-term fix. Use Node Version Manager (nvm) to easily switch to a supported version:

  • Install nvm if you haven't already (it's a tool that lets you manage multiple Node versions on your machine).
  • Run nvm install --lts to install the latest Long-Term Support (LTS) version of Node.js.
  • Switch to this version with nvm use --lts.
  • Verify your version with node -v—you should see a number like v18.x or v20.x (current LTS releases).

Once upgraded, re-run serve -s build and the error should be gone.

Solution 2: Install an Older Compatible serve Version

If upgrading Node.js isn't feasible right now, install an older version of serve that doesn't rely on async/await. Version 11.x works with Node versions as low as 6.x:

  • Uninstall your current global serve instance: npm uninstall -g serve
  • Install version 11: npm install -g serve@11
  • Run serve -s build again—this should resolve the syntax error.

Note: Using an older serve version means missing out on latest features and security patches, so prioritize upgrading Node.js when possible.

内容的提问来源于stack exchange,提问作者Piotr G

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:46:03