使用 multer 和 multer-gridfs-storage 的依赖问题

0 dependencies heroku node.js multer multer-gridfs-storage

首先,我想将我的所有文件推送到heroku以用于托管目的,在这里我无法在heroku上安装multer和multer-gridfs-storage的依赖项,所以这就是为什么我无法在heroku上托管我的网站

remote: -----> Installing dependencies
remote:        Installing node modules
remote:        npm ERR! code ERESOLVE
remote:        npm ERR! ERESOLVE could not resolve
remote:        npm ERR!
remote:        npm ERR! While resolving: multer-gridfs-storage@5.0.2
remote:        npm ERR! Found: multer@1.4.5-lts.1
remote:        npm ERR! node_modules/multer
remote:        npm ERR!   multer@"^1.4.5-lts.1" from the root project
remote:        npm ERR!
remote:        npm ERR! Could not resolve dependency:
remote:        npm ERR! peer multer@"^1.4.2" from multer-gridfs-storage@5.0.2
remote:        npm ERR! node_modules/multer-gridfs-storage
remote:        npm ERR!   multer-gridfs-storage@"^5.0.2" from the root project
remote:        npm ERR!
remote:        npm ERR! Conflicting peer dependency: multer@1.4.4
remote:        npm ERR! node_modules/multer
remote:        npm ERR!   peer multer@"^1.4.2" from multer-gridfs-storage@5.0.2
remote:        npm ERR!   node_modules/multer-gridfs-storage
remote:        npm ERR!     multer-gridfs-storage@"^5.0.2" from the root project
remote:        npm ERR!
remote:        npm ERR! Fix the upstream dependency conflict, or retry
remote:        npm ERR! this command with --force, or --legacy-peer-deps
remote:        npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
remote:        npm ERR!
remote:        npm ERR! See /tmp/npmcache.fbHb6/eresolve-report.txt for a full report.
remote:
remote:        npm ERR! A complete log of this run can be found in:
remote:        npm ERR!     /tmp/npmcache.fbHb6/_logs/2022-10-22T21_00_27_665Z-debug-0.log
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        If you're stuck, please submit a ticket so we can help:
remote:        https://help.heroku.com/
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
Run Code Online (Sandbox Code Playgroud)

Chr*_*ris 8

后缀-lts.1on导致它与来自 的multer@"^1.4.5-lts.1"对等版本约束不匹配。根据npm semver 计算器,满足此版本约束的 Multer 最新版本是.^1.4.2multer-gridfs-storage@5.0.21.4.4

\n

鉴于该版本1.4.5-lts.1似乎是 1.x 开发线的兼容延续,并且 Multer 存在于 NPM 生态系统中,我认为这是 Multer 项目\xc2\xb9 中的一个错误。它的版本号应该满足NPM对semver的理解。

\n

最简单的解决方案是减少对 Multer 版本之间的直接依赖^1.4.5-lts.11.4.4从而满足 Multer GridFS 存储的对等依赖关系。希望您不依赖新版本中的任何功能或错误修复。

\n

我已经针对 Multer 项目提交了一个错误,建议其 LTS 版本约束仍然与 semver 兼容,假设该1.4.5-lts.1版本实际上应该与版本兼容1.4.4及更早版本兼容。

\n
\n

\xc2\xb9我对 semver 或 NPM 的了解不够,不知道这个实现是否真的正确。重要的是 Multer 项目和 NPM 的 semver 实现似乎是冲突的。

\n

我相信该-lts.1后缀被认为是预发行版(即1.4.4-lts.1出现在 之前 1.4.4)。>=1.4.2 <=1.4.4-lts.1semver 计算器似乎同意:使用匹配版本1.4.21.4.3和 的版本约束1.4.4-lts.1,但 1.4.4

\n