简体   繁体   English

在模块导出时变得不确定

[英]Getting undefined on module exports

I'm getting a undefined when exporting a object with multiple functions as fields. 导出具有多个功能的对象作为字段时,出现了不确定的情况。

I'm exporting them as follows: 我将其导出如下:

module.exports = {
  getArticleById: getArticleByIdFromModel
}

When I'm trying to importing 当我尝试导入时

const { getArticleById } = require('../article/Article.selectors.js');
// or 
const selectors = require('../article/Article.selectors.js')

I'm getting both undefined, on getArticleById and selectors. 我在getArticleById和选择器上都未定义。 Is my exporting syntax wrong? 我的导出语法错误吗? or something else? 或者是其他东西? I'm using node 9.11.2 我正在使用节点9.11.2

I was a cyclic dependency. 我是一个周期性的依赖。 I was importing A to B and B to A 我正在将A导入到B并将B导入到A

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM