Node.js 'TypeError:is not a function'

今天项目中遇见一个问题,

A文件module.exports了一个方法a

B文件module.exports了一个方法b

然后我在B文件中引入了a方法运行,是可以的

但是一在A文件中引入b方法,就不可以运行,报错TypeError:is not a function

google了一下

原来是循环依赖的问题

This happened to me many times because of circular dependency, check if you have 2 classes that are requiring each other, remove one of them from requiring the other and the issue should be solved

所以我将其中一个方法挪到了另一个文件里,就可以了

问题: https://stackoverflow.com/questions/33865068/typeerror-is-not-a-function-in-node-js