我正在尝试在Node.js中导入web3库,以便能够处理以太坊智能合约事件,但是我无法进行导入。
我在每个要转换为es5的文件上运行Babel,Node的index.js文件中的导入如下所示:
import Web3 from 'web3'; 当我添加"import Web3 from 'web3'“语句时,我得到这个错误:
webpack:///./node_modules/scrypt/index.js?:3
var scryptNative = __webpack_require__(!(function
webpackMissingModule() { var e = new Error("Cannot find module
'./build/Release/scrypt'"); e.code = 'MODULE_NOT_FOUND'; throw e; } .
()))
^
Error: Cannot find module './build/Release/scrypt'
at webpackMissingModule
(webpack:///./node_modules/scrypt/index.js?:3:84)
at eval (webpack:///./node_modules/scrypt/index.js?:3:181)
at Object../node_modules/scrypt/index.js 这是我的web3版本:(不过,我已经尝试过其他版本,但也不能正常工作)
"web3": "^1.0.0-beta.26"有人知道如何将web3库导入到Node中吗?任何帮助都是非常感谢的。
发布于 2019-04-23 21:50:23
尝试使用此模块的require:
const web3 = require('web3');发布于 2019-04-24 02:59:55
模块名称应用引号引起来
import Web3 from 'web3';发布于 2021-03-26 21:04:01
使用npm install web3安装web3之后,可以在.js文件中使用以下行导入web3模块
var web3 = require('web3');https://stackoverflow.com/questions/55812666
复制相似问题