Closed sakurayang closed 2 years ago
Running your test I get the following error:
/Users/testuser/Projects/test/node_modules/koa/lib/application.js:123
if (typeof fn !== 'function') throw new TypeError('middleware must be a function!');
^
TypeError: middleware must be a function!
at Application.use (/Users/testuser/Projects/test/node_modules/koa/lib/application.js:123:41)
at Object.<anonymous> (/Users/testuser/Projects/test/test.js:12:5)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47
You need to change this:
-app.use(router);
+app.use(router.routes());
node.js version: 14.15.4
npm/yarn and version: 1.11.10
@koa/router
version: 10.1.1koa
version: 0.21.5Code sample:
Expected Behavior:
It will start an HTTP server
Actual Behavior:
So I lookup the lock file and found that
path-to-regexp@^6.1.0
was resolved to 6.2.0... then I dig into node_modules, found the file tree was
but I try
yarn add path-to-regexp@6.1.0
, and the file tree wasso I recommend changing
path-to-regexp@^6.1.0
topath-to-regexp@6.1.0