0

我刚刚了解了 ipfs js,我安装的版本是 0.55.3 版https://www.npmjs.com/package/ipfs),此外我还在使用版本14.17.0(LTS)的 node js和MacOS BigSur 11.4

当我按照链接https://github.com/ipfs/js-ipfs/tree/master/examples/ipfs-101上的教程进行操作时,我总是会收到如下错误:

(node:9857) UnhandledPromiseRejectionWarning: InvalidRepoVersionError: Incompatible repo versions. Automatic migrations disabled. Please migrate the repo manually.
    at IpfsRepo.open (/Users/username/Documents/program/ipfs-node-10/node_modules/ipfs-repo/src/index.js:142:17)
    at async loadRepo (/Users/username/Documents/program/ipfs-node-10/node_modules/ipfs-core/src/components/storage.js:74:5)
    at async Function.start (/Users/username/Documents/program/ipfs-node-10/node_modules/ipfs-core/src/components/storage.js:54:41)
    at async Object.create (/Users/username/Documents/program/ipfs-node-10/node_modules/ipfs-core/src/components/index.js:223:21)
    at async main (/Users/username/Documents/program/ipfs-node-10/index.js:4:16)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:9857) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9857) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

这是我的 index.js 中的代码:

const IPFS = require('ipfs')

async function main () {
  const node = await IPFS.create()
  const version = await node.version()

  console.log('Version:', version.version)
  // ...
}

main()

这是我的 package.json:

{
  "name": "ipfs-node-10",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ipfs": "^0.55.3"
  }

你能帮我找到解决这个问题的方法吗?

4

1 回答 1

0

看起来您的默认 IPFS 存储库是旧版本,并且由于某种原因它不想迁移它。我会做的是:

  1. 只需使用不同的回购await IPFS.create({repo: "example"})

  2. 删除您当前的仓库(如果默认,可能在 中~/.jsipfs

于 2021-06-12T16:52:41.833 回答