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

升级Node.js至20.10.0后Nuxt项目出现importAttributes语法解析错误求助

升级Node.js至20.10.0后Nuxt项目出现importAttributes语法解析错误求助

大家好,我最近把Node.js版本从14.16.0升级到了20.10.0,为了适配新版本解决兼容性问题,我同步把项目里所有依赖包都更新到了最新版本。原本大部分流程都很顺利,但现在启动项目时遇到了一个语法解析错误,具体报错信息如下:

file:///D:/Upgrade-SIR/upgradewebserver/nuxt/node_modules/c12/dist/index.mjs:308
res.config = options.jiti(res.configFile);
^
Error: ParseError: D:\: Support for the experimental syntax 'importAttributes' isn't currently enabled (5:51):
Add @babel/plugin-syntax-import-attributes to the 'plugins' section of your Babel config to enable parsing.
D:/Upgrade-SIR/upgradewebserver/nuxt/nuxt.config.js:5:50

at resolveConfig (file:///D:/Upgrade-SIR/upgradewebserver/nuxt/node_modules/c12/dist/index.mjs:308:24)
at loadConfig (file:///D:/Upgrade-SIR/upgradewebserver/nuxt/node_modules/c12/dist/index.mjs:117:40)
at async loadNuxtConfig (file:///D:/Upgrade-SIR/upgradewebserver/nuxt/node_modules/nuxt/node_modules/@nuxt/kit/dist/index.mjs:468:18)
at async loadNuxt (file:///D:/Upgrade-SIR/upgradewebserver/nuxt/node_modules/nuxt/dist/index.mjs:2266:19)
at async start (file:///D:/Upgrade-SIR/upgradewebserver/nuxt/server/index.js:36:15)

Node.js v18.19.0
[nodemon] app crashed - waiting for file changes before starting...

我已经尝试了以下两种操作,但问题仍然存在:

  • 通过yarn安装了对应的Babel插件作为开发依赖:
    yarn add --dev @babel/plugin-syntax-import-attributes
    
  • 在项目的.babelrc文件中添加了插件配置:
    {
      "plugins": ["@babel/plugin-syntax-import-attributes"]
    }
    

想请教一下社区的各位,有没有什么办法可以修复这个错误呢?

备注:内容来源于stack exchange,提问作者Nithish Kumar

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.20 09:02:57