TypeError: app.use() requires middleware functions
See original GitHub issuethis is the example code:
app.use logger 'dev'
app.use bodyParser.json()
app.use bodyParser.urlencoded()
app.use multer inMemory: yes
when it executes, throw an TypeError from app.use multer: inMemory: yes
:
TypeError: app.use() requires middleware functions
at EventEmitter.use (/Users/ran/github/lbs-app/node_modules/express/lib/application.js:206:11)
at Object.<anonymous> (/Users/ran/github/lbs-app/app.js:69:7)
at Object.<anonymous> (/Users/ran/github/lbs-app/app.js:108:4)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/ran/github/lbs-app/bin/www:7:11)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:124:16)
I was confused at first, because the same code works well on my laptap, and when I check the dependencies’ version, I found multer: 0.1.8 => 1.0.1
…
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
TypeError: app.use() requires middleware functions
app.use requires that you pass it a function which is then used as middleware. You have two instances where you do not do...
Read more >TypeError: app.use() requires middleware functions - Treehouse
use() requires middleware functions. For some reason, I'm getting this error even though it looks like my code matches the instructor's. app.js.
Read more >typeerror: router.use() requires a middleware function but got ...
node app. The error is. TypeError: Router.use() requires middleware function but got a Object. And tracing the error leads me to line 32...
Read more >TypeError: app.use() requires a middleware function
"typeerror: app.use() requires a middleware function". Add Answer | View In TPC Matrix. Technical Problem Cluster First Answered On April 26, ...
Read more >Router.use() requires a middleware function but got a Object ...
TypeError : Router. use() requires a middleware function but got a Object | Node Js error. 10K views 1 year ago.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sagarpandav Could it be that you have forgot to do
module.exports =
in yourroutes/index.js
file?So I’m thinking you had the same problem as me. I had my multer configuration in my express config file, so now I’m rushing a fix to get it nested in to a route.
for example: in my routes.js file
and in /api/uploads/index.js
I’m still finishing up my code, but that’s a rough idea of what the change is. Good luck!