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

新安装Node-RED启动报错:Unexpected token '.',求解决方法

Node-RED启动报错:SyntaxError: Unexpected token '.' 解决方法

错误原因

报错里的sendEvent?.destination?.node使用了可选链操作符(?.),这是ES2020的语法特性,仅Node.js 14.0.0及以上版本支持。你的Node.js版本过低,导致无法解析该语法,进而启动失败。

解决步骤

  1. 检查当前Node.js版本
    运行命令查看版本:

    node -v
    

    若输出版本低于v14.0.0,必须升级Node.js。

  2. 升级Node.js(Debian系统)

    • 卸载旧版本(若通过apt安装):
      apt remove nodejs npm -y
      
    • 添加NodeSource官方LTS版本源(以18.x为例,长期支持更稳定):
      curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
      apt-get install -y nodejs
      
    • 验证升级结果:
      node -v
      
      确认版本为v18.x或更高。
  3. 重新安装Node-RED

    • 卸载旧版本:
      npm uninstall -g node-red
      
    • 全局重新安装:
      npm install -g node-red
      
  4. 启动Node-RED
    运行命令:

    node-red
    

    此时应能正常启动,不会再出现语法错误。

内容的提问来源于stack exchange,提问作者Dario Armellin

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.11 01:52:30