1

My application with file upload worked good with express 3.x, but after upgrade express module to 4.x, it didn't work anymore. After searching, I knew the reason,because of the middleware for processing multipart/form-data request body data was removed from the bodyParser middleware. Then I tried to install multer, but can't install it, following error : npm ERR! Error: No compatible version found: busboy@'^0.2.6' npm ERR! Valid install targets:

So what can i do next with my application, I really want to use express 4.x, anyone help me please? Thank you.

2
  • If you run npm info busboy, is there a 0.2.6 entry in the versions list? If not, you might be behind a proxy that has an outdated npm repository. If it is there, then perhaps your npm binary is outdated. What does npm --version say? Commented Jun 4, 2014 at 15:59
  • with npm info busboy,I see it have version 0.2.6. my npm version is 1.3.5, and node version 0.10. Commented Jun 4, 2014 at 16:04

2 Answers 2

3

You need to use the body-parser middleware along with multer, since they are no longer bundled in with express.

var express = require('express') var bodyParser = require('body-parser') var multer = require('multer') var app = express() app.use(bodyParser()) //Formerly app.use(express.bodyParser()) app.use(multer({ dest: './uploads/'})) //Formerly app.use(express.multipart()) 
Sign up to request clarification or add additional context in comments.

3 Comments

As you said, I installed body-parser module first with this command : npm install body-parser, then I installed multer with : npm install multer. But can't install multer. It's still display this errors : npm ERR! Error: No compatible version found: busboy@'^0.2.6' npm ERR! Valid install targets: npm ERR! ["0.0.1","0.0.2","0.0.3","0.0.4","0.0.5","0.0.6","0.0.7","0.0.8","0.0.9 ","0.0.10","0.0.11","0.0.12","0.0.13","0.0.14","0.0.15","0.1.0","0.1.1","0.2.0", "0.2.1","0.2.2","0.2.3","0.2.4","0.2.5","0.2.6"]. So how can I use multer if it haven't completed installing ??
@Kate Have you tried installing the busboy dependency manually?
yes, I installed busboy too, but still can't install multer.Errors still like this : npm ERR! Error: No compatible version found: busboy@'^0.2.6' npm ERR! Valid install targets:
0

The caret (^) indicates that you want to install a version of Busboy that is compatible with (in this case) 0.2.6.

The package that npm uses for comparing versions (semver) added support for this in version 2.1.0. npm uses that release since version 1.3.7.

Your npm version doesn't understand what to do when you tell it to install '^0.2.6'. It's confused by the caret symbol.

According to your comment, you're running an npm installation that is older than that (1.3.5).

The solution is to update npm. Your node installation itself is probably outdated as well, since new releases of npm are usually bundled with node.

2 Comments

but are there any solution except this solution? I dont want to upgrade my node or npm, because upgrading npm or node , it will affect other applications are running.
Are you sure that upgrading will cause problems? If so, then you can use nvm to run multiple versions of node simultaneously. You can choose what version to use per project. But if you really must then you can also (A) download the packages and dependencies manually (from Github) and place them in the correct directories or (B) install a new npm version locally, install the packages and then copy-and-paste the resulting node_modules directory.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.