Error: node yarn start 하자마자 발생하는 runtime 오류

에러메시지

/Users/archmagece/work/aprobit-service/apronode/node_modules/express/lib/router/index.js:458
      throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
      ^

TypeError: Router.use() requires a middleware function but got a Object
    at Function.use (/Users/archmagece/work/aprobit-service/apronode/node_modules/express/lib/router/index.js:458:13)
    at Function.<anonymous> (/Users/archmagece/work/aprobit-service/apronode/node_modules/express/lib/application.js:220:21)
    at Array.forEach (<anonymous>)
    at Function.use (/Users/archmagece/work/aprobit-service/apronode/node_modules/express/lib/application.js:217:7)
    at Object.<anonymous> (/Users/archmagece/work/aprobit-service/apronode/app/app.js:22:5)
    at Module._compile (internal/modules/cjs/loader.js:1157:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
    at Module.load (internal/modules/cjs/loader.js:1001:32)
    at Function.Module._load (internal/modules/cjs/loader.js:900:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
error Command failed with exit code 1.

에러발생 코드

app.use('/api/v2/public', require('./routes/public'))

해결

./routes/public.js 맨 아래에 다음코드 추가

module.exports = router;

export를 안했네.. 이런짓을???

노드에 익숙하지 않긴한데 에러메시지 보고 한번에 알아채지 못해서 약간의 시간낭비

Leave a Reply

Your email address will not be published.

 characters available