所以我目前正在使用安全帽上的交易机器人进行练习。我的问题是,当我想运行我的脚本时,会出现此错误:
import './ABIConstants.js';
^^^^^^
SyntaxError: Cannot use import statement outside a module
Run Code Online (Sandbox Code Playgroud)
有了这个建议:
(node:1284) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
Run Code Online (Sandbox Code Playgroud)
但是,当我按照它告诉我的那样设置“type”:“module”时,我收到此错误:
hardhat.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename hardhat.config.js to end in .cjs, change the requiring code to use dynamic import() …Run Code Online (Sandbox Code Playgroud)