Dependency problem using multer and multer-gridfs-storage
Asked Answered
P

6

1

First of all here I want to push my all files to heroku for hosting purpose and here I am not able to install dependency of multer and multer-gridfs-storage on heroku so that's why I am not able to host my website on 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: [email protected]
remote:        npm ERR! Found: [email protected]
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 [email protected]
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: [email protected]
remote:        npm ERR! node_modules/multer
remote:        npm ERR!   peer multer@"^1.4.2" from [email protected]
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
Pow answered 22/10, 2022 at 21:9 Comment(0)
M
9

The -lts.1 suffix on multer@"^1.4.5-lts.1" causes it not to be matched by the peer version constraint ^1.4.2 coming from [email protected]. According to the npm semver calculator, the latest version of Multer that satisfies this version constraint is 1.4.4.

Given that version 1.4.5-lts.1 appears to be a compatible continuation of the 1.x development line, and that Multer exists in the NPM ecosystem, I would argue that this is a bug in the Multer project¹. Its version numbers should satisfy NPM's understanding of semver.

Your easiest solution will be to reduce your direct dependency on Multer from version ^1.4.5-lts.1 to version 1.4.4, which satisfies the peer dependency from Multer GridFS Storage. Hopefully you don't depend on any features or bug fixes in the newer version.

I have submitted a bug against the Multer project suggesting that its LTS version constraints remain compatible with semver, assuming the 1.4.5-lts.1 version is actually supposed to be compatible with version 1.4.4 and earlier.


¹I am not knowledgeable enough in semver or NPM to know whether this implementation is actually correct. What matters is that the Multer project and NPM's implementation of semver appear to be in conflict.

I believe the -lts.1 suffix is recognized as a prerelease (i.e., 1.4.4-lts.1 would come before 1.4.4). The semver calculator seems to agree: using a version constraint of >=1.4.2 <=1.4.4-lts.1 matches versions 1.4.2, 1.4.3, and 1.4.4-lts.1, but not 1.4.4.

Maclaine answered 23/10, 2022 at 11:46 Comment(1)
The 1.4.5-lts.1 version contains breaking changes which is why we haven't released it as just 1.4.6. The breaking change is that support for older versions of Node.js is now broken. If anyone contributes a patch so that we can address the security issue without breaking compatibility we'll release that as 1.4.6Bacteriology
C
0

Its seems that the multer is not compatible with the latest mongodb so in your backend folder install the mongodb version 5.9.1

Just put this code in your CMD

npm i [email protected]
Cordie answered 22/2 at 8:57 Comment(0)
U
0

I found a solution to the installation issue with multer-storage-cloudinary. The problem was caused by a dependency conflict with [email protected]. To resolve it, I used the --legacy-peer-deps flag during installation:

npm install multer-storage-cloudinary --legacy-peer-deps

This resolved the issue, and the package is now installed successfully😊.

Uptown answered 19/8 at 20:25 Comment(0)
M
0

If you see the error logs files you can find the dependency solution. It says as below quoted

Could not resolve dependency: peer cloudinary@"^1.21.0" from [email protected]

So install npm install cloudinary@^1.21.0

It will resolve the dependency issue

Moshemoshell answered 5/10 at 10:15 Comment(0)
K
-1

npm i multer-gridfs-storage --legacy-peer-deps

above command works just fine.

Kunkle answered 13/5, 2023 at 19:20 Comment(0)
B
-1

change the version of multer, install version 1.4.4

Brittney answered 31/3 at 9:42 Comment(1)
Like the answer from a year and a half ago says?Maclaine

© 2022 - 2024 — McMap. All rights reserved.