0

在终端中运行命令“knex migrate:latest”时,出现此错误...

➜  WebpackExpressKnexPackage git:(knexInit) ✗ knex migrate:latest
Using environment: development
/usr/local/lib/node_modules/knex/bin/cli.js:127
      pending = initKnex(env).migrate.latest().spread(function(batchNo, log) {
                                               ^

TypeError: initKnex(...).migrate.latest(...).spread is not a function
    at Command.<anonymous> (/usr/local/lib/node_modules/knex/bin/cli.js:127:48)
    at Command.listener (/usr/local/lib/node_modules/knex/node_modules/commander/index.js:315:8)
    at Command.emit (events.js:210:5)
    at Command.parseArgs (/usr/local/lib/node_modules/knex/node_modules/commander/index.js:653:12)
    at Command.parse (/usr/local/lib/node_modules/knex/node_modules/commander/index.js:475:21)
    at Liftoff.invoke (/usr/local/lib/node_modules/knex/bin/cli.js:186:13)
    at Liftoff.<anonymous> (/usr/local/lib/node_modules/knex/node_modules/liftoff/index.js:198:16)
    at module.exports (/usr/local/lib/node_modules/knex/node_modules/flagged-respawn/index.js:17:3)
    at Liftoff.<anonymous> (/usr/local/lib/node_modules/knex/node_modules/liftoff/index.js:190:9)
    at /usr/local/lib/node_modules/knex/node_modules/liftoff/index.js:164:9
    at /usr/local/lib/node_modules/knex/node_modules/v8flags/index.js:108:14
    at /usr/local/lib/node_modules/knex/node_modules/v8flags/index.js:35:14
    at /usr/local/lib/node_modules/knex/node_modules/v8flags/index.js:47:7
    at processTicksAndRejections (internal/process/task_queues.js:75:11)

我已经从我的计算机中完全删除了 Brew 和 NPM 的所有东西,重新安装它们并多次完全重写我的服务器,希望找到解决方案,但是在每个角落我都遇到了同样的错误,.spread() 不是功能。

在这里您可以看到我正在运行当前版本的 Knex.js:

➜  WebpackExpressKnexPackage git:(knexInit) ✗ knex -V
Knex CLI version:  0.14.2
Local Knex version:  0.21.16

但是,我无法发现如何卸载 Knex-Cli:

➜  WebpackExpressKnexPackage git:(knexInit) ✗ npm uninstall --save knex
removed 32 packages and audited 714 packages in 2.558s
found 0 vulnerabilities

➜  WebpackExpressKnexPackage git:(knexInit) ✗ knex -V
Knex CLI version:  0.14.2
Local Knex version:  undefined

我遇到了一个线程,它提到它可能是遗留的 Bluebird 代码,但是在任何人能够提供答案之前,该线程就被关闭了。希望问题出在 Knex CLI 中,我已成功卸载 Knex,但无法删除 Knex CLI。我完全不知所措。我学到了很多东西,但没有什么能让我越过这堵墙。谁能帮我解决这个问题?

4

2 回答 2

0

你试过跑步npm uninstall -g knex吗?

于 2021-01-20T00:36:41.027 回答
-1

我对机器内部工作原理的了解有限。经过四年的路径更改和安装/卸载/更新(谁真的知道我犯了哪些其他错误;即,我有无用的 package.json 文件散落在各处),我得出的结论是我需要白手起家。我最终在没有使用任何备份的情况下完全恢复了我的机器的出厂设置,然后从头开始重新安装 Homebrew 和 Node(以及我需要的其他库)。我不确定,但我的理论是我的机器太拥挤了,以至于它本身有点混乱。我不能确定这是问题所在,但恢复出厂设置是一个有效的解决方案。

谢谢各位的意见。

于 2021-02-01T16:52:49.473 回答