노드에 외부 jQuery 파일을 사용하는 데 문제가 있습니다. 내가 실행할 필요가 있지만 작동하지 않는 몇 가지 기능이 있습니다. 내가 테스트 할 수있는 간단한 함수를 만들었지 만 계속 오류 메시지가 발생했습니다 TypeError : Object # 'alert_helloworld'메서드가 없습니다. 여기 내 두 파일은 다음과 같습니다외부 jQuery 파일이있는 Node.js
example.js
var jsdom = require('jsdom');
var templateparser = require('./templateparser.js');
var test = templateparser.alert_helloworld();
templateparser.js
function alert_helloworld(){
console.log("Hello World");
return false;
}
HELP는 !!!! http://nodejs.org/docs/latest/api/modules.html
외부 파일을 재발견하고 싶지 않습니다. 나는 그것을 똑같이 지키고 싶다. 이것은 가능한가? – user1146581
@ user1146581 예/아니요. jsdom에 자바 스크립트 파일로 삽입하거나 노드의 AST 파서를 통해 삽입 할 수 있습니다. 그렇지 않은 경우에는 파일에서 정의한 "전역"변수에 액세스 할 수 없습니다. – Raynos
그래서 내가 물어 보는 것 같아, 어떻게 jsdom에 자바 스크립트로 주입합니까? – user1146581