gpt4 book ai didi

node.js - 错误: Cannot migrate models not attached to this datasource: loopback-datasource-juggler

转载 作者:太空宇宙 更新时间:2023-11-03 22:31:11 26 4
gpt4 key购买 nike

我指的是下面的链接来设置环回框架并创建简单的 API

https://docs.strongloop.com/display/public/LB/Getting+started+with+LoopBack

但是当我尝试将 API 连接到数据源时,出现以下错误,但不知道原因是什么以及如何解决它。请任何人都可以帮助我解决这个问题。

Error: Cannot migrate models not attached to this datasource: CoffeeShop
at /Users/emotian/Development/loopback-getting-started/node_modules/loopback-datasource-juggler/lib/datasource.js:822:14
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickDomainCallback (node.js:390:13)
at process.fallback (/Users/emotian/Development/loopback-getting-started/node_modules/loopback/node_modules/continuation-local-storage/node_modules/async-listener/index.js:450:15)
at Function.Module.runMain (module.js:443:11)
at startup (node.js:139:18)
at node.js:968:3

最佳答案

确保先添加数据源,然后安装连接器。

lb datasource mysqlDb
npm install --save loopback-connector-mysql

检查 server/datasources.json 是否一切正确

删除旧的 models/coffeeshop.js/json 以防万一

然后运行

lb model

然后选择新的数据源并添加所需的字段。

关于node.js - 错误: Cannot migrate models not attached to this datasource: loopback-datasource-juggler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36976365/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com