0
내가 아닌 다른에서는, Cannot call method 'checkId' of undefined
node.js
하나의 모듈에 직면하고의 정의되지 않은 방법 'checkId'을 호출 할 수 없습니다, 호출 할 때 :형식 오류 : 때문에 널 (null) 프로토 타입
res = EntityCommons.prototype.checkId(res,json[RE_FIELD_ID]);
내가 3 개 node.js
모듈이 Host
, Request
동일한 디렉토리에 EntityCommons
이 있습니다.
Request
를 들면 다음과 같습니다 :
var EntityCommons = require("./EntityCommons.js");
console.log("XXEntityCommons null or undefined : " +
_.isNullOrUndefined(EntityCommons));
console.log("XXEntityCommons prototype null/und: " +
_.isNullOrUndefined(EntityCommons.prototype));
Host
를 들어 다음과 같은 Host
및 Request
이 EntityCommons
을 필요로
var EntityCommons = require("./EntityCommons.js");
console.log("EntityCommons null or undefined : " +
_.isNullOrUndefined(EntityCommons));
console.log("EntityCommons prototype null/und: " +
_.isNullOrUndefined(EntityCommons.prototype));
I 출력을 선택하면, 내가 얻을 :
EntityCommons null or undefined : false
EntityCommons prototype null/und: true
XXEntityCommons null or undefined : false
XXEntityCommons prototype null/und: false
01 년, EntityCommons
의 프로토 타입은 null
입니다. 이것은 말이되지 않습니다. 무엇이이 문제를 일으킬 수 있습니까?
var Host = require("./Host.js");
이이 순환 문제인가 :
업데이트
EntityCommons
은 다음과 너무 Host
이 필요?
이 순환 문제인가 : 그것은 또한 객체와 함께 작동
: 즉
, 내 모듈의 상단에있는 함수를 수출에 의해 시작? 예. 이 http://nodejs.org/api/modules.html#modules_cycles 단락의 이유 설명 –