我正在根据教程学习 ipfs js,但是当我在关注时,我在终端中输入 node main.js 时遇到问题,如下所示:
/Users/username/Documents/coding/ipfs-test/node_modules/lock-me/src/unix.js:9
(cb) => fs.stat(name, (err, stats) => {
^
TypeError: fs.stat is not a function
at waterfall (/Users/username/Documents/coding/ipfs-test/node_modules/lock-me/src/unix.js:9:16)
at nextTask (/Users/username/Documents/coding/ipfs-test/node_modules/async/waterfall.js:16:14)
at exports.default (/Users/username/Documents/coding/ipfs-test/node_modules/async/waterfall.js:26:5)
at unixLock (/Users/username/Documents/coding/ipfs-test/node_modules/lock-me/src/unix.js:8:3)
at lock (/Users/username/Documents/coding/ipfs-test/node_modules/lock-me/src/index.js:53:5)
at Object.exports.lock (/Users/username/Documents/coding/ipfs-test/node_modules/ipfs-repo/src/lock.js:23:3)
at IpfsRepo._openLock (/Users/username/Documents/coding/ipfs-test/node_modules/ipfs-repo/src/index.js:168:18)
at waterfall (/Users/username/Documents/coding/ipfs-test/node_modules/ipfs-repo/src/index.js:96:20)
这是用 main.js 编写的代码:
const IPFS = require('ipfs');
console.log("Imported IPFS");
const mynode = new IPFS();
console.log("Starting Server");
mynode.on('ready', async () => {
console.log("Server Started");
const version = await mynode.version();
console.log(version.version);
});
信息:我使用的是 node js 版本 8.13.0,我使用的 IPFS JS 版本是 0.32.3,使用 OS MacOS Bigsur 11.4
这个问题有解决方案吗?谢谢^^