我在loopback应用程序中创建模型之间的关系,但是当我执行以下命令时
slc loopback:relation
我抛出以下错误。
错误
(node:6444) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'type' of undefined
events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'type' of undefined
at C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\inquirer\lib\objects\choices.js:16:12
at Array.map (native)
at new module.exports (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\inquirer\lib\objects\choices.js:15:26)
at Prompt.module.exports (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\inquirer\lib\prompts\base.js:43:24)
at new Prompt (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\inquirer\lib\prompts\list.js:26:8)
at PromptUI.fetchAnswer (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\inquirer\lib\ui\prompt.js:77:16)
at tryCatcher (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\rx\dist\rx.js:63:31)
at InnerObserver.Rx.FlatMapObservable.InnerObserver.next (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\rx\dist\rx.js:2140:43)
at InnerObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\rx\dist\rx.js:1762:31)
at InnerObserver.tryCatcher (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\rx\dist\rx.js:63:31)
at AutoDetachObserverPrototype.next (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\rx\dist\rx.js:5883:51)
at AutoDetachObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\rx\dist\rx.js:1762:31)
at InnerObserver.next (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\rx\dist\rx.js:3547:65)
at InnerObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\rx\dist\rx.js:1762:31)
at InnerObserver.tryCatcher (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\rx\dist\rx.js:63:31)
at AutoDetachObserverPrototype.next (C:\Users\DELL5110\AppData\Roaming\npm\node_modules\strongloop\node_modules\rx\dist\rx.js:5883:51)
slc -v
strongloop v6.0.3 (node v6.9.2)
├── strong-arc@1.8.9 (3dd25ac)
├── strong-build@2.1.2 (a98f310)
├── strong-deploy@3.1.4 (9b29df0)
├── strong-mesh-models@8.1.0 (62e539b)
├── strong-pm@5.2.3
├── strong-registry@1.1.6 (f8c2339)
├── strong-start@1.3.4 (28c261d)
├─┬ strong-supervisor@3.3.3
│ └── strong-agent@2.1.1 (b51fc45)
├── generator-loopback@1.25.0 (6a0e2c0)
├── node-inspector@0.7.5 (16841d6)
└── nodefly-register@0.3.3
节点:6.9.2 npm:3.10.9
我正在使用Mongodb模型
这是我的项目
答案 0 :(得分:0)
问题由https://github.com/strongloop/loopback/issues/3090#issuecomment-274183440解决 问题是错误地将model-config.json文件放在common / models /目录中。 如果某人遇到环回的相同问题,请检查您是否正确地遵循了项目结构,特别是模型目录中没有额外或不需要的东西。