-
"bundle": "npm run build && ncc build bootstrap.js -o build
-
cd build
-
node .\index.js
-
错误如下:
node:1164) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
(Use node --trace-deprecation ... to show where the warning was created)
2025-10-31 09:16:55.797 ERROR 1164 TypeError: Cannot read properties of undefined (reading 'routerOptions')
at MidwayWebRouterService.addController (F:\nongye\cool\cool-admin-midway\build\index.js:99883:59)
at MidwayWebRouterService.analyzeController (F:\nongye\cool\cool-admin-midway\build\index.js:99846:18)
at MidwayWebRouterService.analyze (F:\nongye\cool\cool-admin-midway\build\index.js:99839:14)
at MidwayWebRouterService.getRouterTable (F:\nongye\cool\cool-admin-midway\build\index.js:100069:24)
at KoaControllerGenerator.loadMidwayController (F:\nongye\cool\cool-admin-midway\build\index.js:92722:63)
at MidwayKoaFramework.loadMidwayController (F:\nongye\cool\cool-admin-midway\build\index.js:105300:30)
at MidwayKoaFramework.run (F:\nongye\cool\cool-admin-midway\build\index.js:105323:20)
at MidwayFrameworkService.runFramework (F:\nongye\cool\cool-admin-midway\build\index.js:98340:41)
at MidwayLifeCycleService.init (F:\nongye\cool\cool-admin-midway\build\index.js:98660:37)
at async ObjectCreator.doInitAsync (F:\nongye\cool\cool-admin-midway\build\index.js:96189:17)
2025-10-31 09:16:55.802 INFO 1164 [midway:bootstrap] exit with code:1
具体代码如下:
addController(controllerClz, controllerOption, resourceOptions = {}, functionMeta = false) {
var _a;
if (resourceOptions && typeof resourceOptions === 'boolean') {
functionMeta = resourceOptions;
resourceOptions = undefined;
}
if (!resourceOptions) {
resourceOptions = {};
}
const controllerId = (0, decorator_1.getProviderName)(controllerClz);
debug([core]: Found Controller ${controllerId}.);
const id = (0, decorator_1.getProviderUUId)(controllerClz);
controllerOption.routerOptions = controllerOption.routerOptions || {};
let priority;
// implement middleware in controller
"bundle": "npm run build && ncc build bootstrap.js -o build
cd build
node .\index.js
错误如下:
node:1164) [DEP0040] DeprecationWarning: The
punycodemodule is deprecated. Please use a userland alternative instead.(Use
node --trace-deprecation ...to show where the warning was created)2025-10-31 09:16:55.797 ERROR 1164 TypeError: Cannot read properties of undefined (reading 'routerOptions')
at MidwayWebRouterService.addController (F:\nongye\cool\cool-admin-midway\build\index.js:99883:59)
at MidwayWebRouterService.analyzeController (F:\nongye\cool\cool-admin-midway\build\index.js:99846:18)
at MidwayWebRouterService.analyze (F:\nongye\cool\cool-admin-midway\build\index.js:99839:14)
at MidwayWebRouterService.getRouterTable (F:\nongye\cool\cool-admin-midway\build\index.js:100069:24)
at KoaControllerGenerator.loadMidwayController (F:\nongye\cool\cool-admin-midway\build\index.js:92722:63)
at MidwayKoaFramework.loadMidwayController (F:\nongye\cool\cool-admin-midway\build\index.js:105300:30)
at MidwayKoaFramework.run (F:\nongye\cool\cool-admin-midway\build\index.js:105323:20)
at MidwayFrameworkService.runFramework (F:\nongye\cool\cool-admin-midway\build\index.js:98340:41)
at MidwayLifeCycleService.init (F:\nongye\cool\cool-admin-midway\build\index.js:98660:37)
at async ObjectCreator.doInitAsync (F:\nongye\cool\cool-admin-midway\build\index.js:96189:17)
2025-10-31 09:16:55.802 INFO 1164 [midway:bootstrap] exit with code:1
具体代码如下:
addController(controllerClz, controllerOption, resourceOptions = {}, functionMeta = false) {
var _a;
if (resourceOptions && typeof resourceOptions === 'boolean') {
functionMeta = resourceOptions;
resourceOptions = undefined;
}
if (!resourceOptions) {
resourceOptions = {};
}
const controllerId = (0, decorator_1.getProviderName)(controllerClz);
debug(
[core]: Found Controller ${controllerId}.);const id = (0, decorator_1.getProviderUUId)(controllerClz);
controllerOption.routerOptions = controllerOption.routerOptions || {};
let priority;
// implement middleware in controller