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

编译Solidity代码时导入OpenZeppelin遇Parser Error问题咨询

Solidity编译解析错误:原因与解决方法

编译错误信息

Retrieving compiler information:
Compiler using remote version: 'latest', solidity version: 0.8.17+commit.8df45f5f.Emscripten.clang
ParserError: Expected string literal (path), "*" or alias list.
--> c:/Users/manis/Desktop/React_Native/contracts/NFTMarketplace.sol:6:8:
|
6 | import “@openzeppelin/contracts/utils/Counters.sol”;
| ^

Compilation failed with 1 errors

错误原因

  • 第6行的import语句使用了中文双引号(“”),Solidity语法要求导入路径必须使用英文双引号("")或英文单引号(''),编译器无法识别中文标点,因此触发解析错误。

解决方法

  • 把导入语句里的中文引号替换为英文引号,修正后的代码:
import "@openzeppelin/contracts/utils/Counters.sol";
  • 全面检查合约文件,确保所有字符串、导入语句使用的都是英文标点,避免类似的中文符号混入代码导致编译失败。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 15:35:40