Ember 在组件目录中找不到模块 'mysql'
Ember could not find module 'mysql' in components directory
我最近开始遇到无法在 component.js
中导入 'mysql' 模块的问题
export default Component.extend({
actions: {
createPost: function (newPost) {
var mysql = require('mysql');
}
}
});
此代码后跟此错误:
There was an error running your app in fastboot. More info about the error:
Error: Could not find module `mysql` imported from `dummy/components/create-new-post/component`
因此文件存在于 api-directory/tests/dummy/app/components/create-new-post/component.js
但是,我在 api-directory/server/mocks/posts.js 中有这样的功能,当我使用相同的 'var mysql = require('mysql') 时,它似乎在那里工作正常;'
我根本无法解决这个问题,到处寻找解决方案。谁能就这个最简单的解决方案提供帮助和启发?谢谢
算了,我是个白痴,不知道后端和前端的区别。我将商店服务注入到组件中,并使用 createRecord 函数和 save 将记录传递到后端,在那里我可以成功执行查询。
我最近开始遇到无法在 component.js
中导入 'mysql' 模块的问题export default Component.extend({
actions: {
createPost: function (newPost) {
var mysql = require('mysql');
}
}
});
此代码后跟此错误:
There was an error running your app in fastboot. More info about the error:
Error: Could not find module `mysql` imported from `dummy/components/create-new-post/component`
因此文件存在于 api-directory/tests/dummy/app/components/create-new-post/component.js
但是,我在 api-directory/server/mocks/posts.js 中有这样的功能,当我使用相同的 'var mysql = require('mysql') 时,它似乎在那里工作正常;'
我根本无法解决这个问题,到处寻找解决方案。谁能就这个最简单的解决方案提供帮助和启发?谢谢
算了,我是个白痴,不知道后端和前端的区别。我将商店服务注入到组件中,并使用 createRecord 函数和 save 将记录传递到后端,在那里我可以成功执行查询。