Closed 1097872822 closed 3 years ago
hi,请再拉取最新代码运行一下,会打印出更有用的错误信息。这里可能是文件夹名称的问题。
之前的问题都解决了,包含中文的文件名也移至全英文文件夹,但gulp mock启动仍然出现ruter[methor] is not a function: n*【info】... [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\delete\api\v1\booklists{id}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\delete\api\v1\orders{id}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\delete\api\v1\reviews{id}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\booklists\recommend{phone}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\booklists\search.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\booklists\users{id}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\booklists{id}\books.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\booklists{id}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\books\authors{author}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\books\classifications{class}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\books\isbn{isbn}\collections.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\books\isbn{isbn}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\books\ranking.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\books\recommend{phone}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\books\search\advanced.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\books\search.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\books\tags{tag}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\books{id}\collections.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\books{id}\reviews.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\books{id}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\classifications{id}\sons.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\codes\check.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\images.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\libraries{id}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\orders\return.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\orders\users{phone}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\orders{id}\take.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\orders{id}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\reviews{id}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\users{phone}\reviews.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\users{phone}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\get\api\v1\users.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\post\api\v1\booklists{id}\favorite.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\post\api\v1\booklists{id}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\post\api\v1\booklists.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\post\api\v1\books{id}\reviews.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\post\api\v1\codes.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\post\api\v1\orders{id}\cancel.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\post\api\v1\orders{id}\renew.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\post\api\v1\orders{id}.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\post\api\v1\orders.jso url: n error: TypeError: router[method] is not a function [Error] Add mock api failed, method: d:\booking\weapp-library\weapp-library\simplest-mock-server\example\post\api\v1\users{phone}.jso url: n error: TypeError: router[method] is not a function open mock server at localhost:3000
@1097872822 额..我知道了,是因为我在代码里解析路径时使用了 /
,而 windows 下都是 \
。我想想咋解决。
更新了下代码。我这边没有 windows 环境可以测试,需要你拉下来跑一下 @1097872822
@imageslr 好的,感谢
问题依旧...TypeError: router[method] is not a function
再贴下完整日志吧。
如果只是想开发预览,可以参考 README 的“云开发”部分,把 simplest-mock-server 上传到云托管。这一步也很简单。
另外云托管部分我已按照文档做了,并且改了request.js文件响应的内容
好。我大概知道问题是啥了,我之后在 windows 测试吧。可以先用云托管调试
好 再次感谢负责的开发者 哈哈~
新代码我在 windows 测试已经没有问题了,可以再试试。
D:\桌面的东西\预约功能\weapp-library\simplest-mock-server>gulp mock [11:26:04] Using gulpfile D:\桌面的东西\小程序\weapp-library\simplest-mock-server\gulpfile.js [11:26:04] Starting 'mock'... [11:26:04] Finished 'mock' after 93 ms [11:26:04] [nodemon] 2.0.7 [11:26:04] [nodemon] to restart at any time, enter)
at Object. (D:\桌面的东西\小程序\weapp-library\simplest-mock-server\router.js:50:8)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object. (D:\桌面的东西\小程序\weapp-library\simplest-mock-server\server.js:12:16)
application has crashed!
[11:26:04] [nodemon] app crashed - waiting for file changes before starting...
rs
[11:26:04] [nodemon] watching path(s): example*\ server.js router.js [11:26:04] [nodemon] watching extensions: js,json [11:26:04] [nodemon] startingnode ./server.js --dir example --port 3000
[INFO] Reading mock template file: D:\桌面的东西\小程序\weapp-library\simplest-mock-server\example\DELETE\users{id}.json [INFO] Reading mock template file: D:\桌面的东西\小程序\weapp-library\simplest-mock-server\example\GET\api\v1\users{id}.json [INFO] Reading mock template file: D:\桌面的东西\小程序\weapp-library\simplest-mock-server\example\GET\echo.json [INFO] Reading mock template file: D:\桌面的东西\小程序\weapp-library\simplest-mock-server\example\GET\users.json [INFO] Reading mock template file: D:\桌面的东西\小程序\weapp-library\simplest-mock-server\example\POST\users.json D:\桌面的东西\小程序\weapp-library\simplest-mock-server\router.js:69 routermethod; ^ TypeError: router[method] is not a function at D:\桌面的东西\小程序\weapp-library\simplest-mock-server\router.js:69:17 at Array.forEach (请问博主我在使用gulp mock遇到router.js中的router[method] is not a function的问题,我找过很多相关解决办法但依旧未能解决,请问是否是我node版本 与 gulp版本问题所导致的呢?若您有空看到并给出一些建议,万分感谢~【node isv12.16.3 & gulp is 3.9.1,并且已经npm install】