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

Hyperledger区块链浏览器执行npm run start时遇语法错误求助

解决Hyperledger Explorer启动时start.sh: Syntax error: "(" unexpected错误

问题场景

在生产网络中部署Hyperledger Explorer,执行npm start时触发如下错误:

************************************************************************************
**************************** Hyperledger Explorer **********************************
************************************************************************************
./start.sh: 24: Syntax error: "(" unexpected
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! hyperledger-explorer@1.1.8 app-start: `./start.sh`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the hyperledger-explorer@1.1.8 app-start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/conqueror/.npm/_logs/2022-10-05T02_01_23_907Z-debug.log
ERROR: "app-start" exited with 2.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hyperledger-explorer@1.1.8 start: `run-s build app-start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the hyperledger-explorer@1.1.8 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/conqueror/.npm/_logs/2022-10-05T02_01_23_940Z-debug.log

解决方法

该错误核心原因是start.sh使用了Bash专属语法(如数组、特定括号写法),但执行脚本时调用了不支持这些语法的Shell解释器(比如Debian/Ubuntu系统默认/bin/sh是Dash的软链接)。以下是几种可行的修复方案:

方案1:修正start.sh的Shebang行

  1. 打开blockchain-explorer目录下的start.sh文件
  2. 检查第一行是否为#!/bin/bash,如果是#!/bin/sh,修改为#!/bin/bash
  3. 保存文件后,重新执行npm start

方案2:修改package.json中的启动脚本

  1. 打开package.json文件,找到scripts字段下的app-start项
  2. 将原内容./start.sh修改为bash start.sh
  3. 保存文件后,重新执行npm start

方案3:直接用Bash执行脚本

跳过npm的脚本调用,直接在终端执行:

bash start.sh

方案4:调整系统默认Shell(生产环境需谨慎)

如果系统默认Shell不是Bash,可临时切换:

sudo ln -sf /bin/bash /bin/sh

注意:此操作会修改系统全局默认Shell,可能影响其他依赖/bin/sh的脚本,生产环境操作前需充分评估风险。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 09:26:16