Skip to content

arpitprod/node-circular-dependcy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-circular-dependcy

Reproducing Node Circular dependcy with ES6 Class

Based on

https://coderwall.com/p/myzvmg/circular-dependencies-in-node-js

https://gist.github.com/lperrin/5934098

https://nodejs.org/api/modules.html#modules_cycles

node index.js

will see an error TypeError: moduleA is not a constructor

How to fix

Update a.js with below code and do node index.js


class ModuleA {

	
}

module.exports = ModuleA;

var moduleB = require('./b');

ModuleA.prototype.hello = function(){
	console.log('hello!');
}

About

Reproducing Node Circular dependcy with ES6 Class

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%