2016-07-11 2 views
2

nodejs server/client 절약 예제를 실행하려고하는데 실행할 수 없습니다. 처음에는 내 package.json 파일에 의존성으로 중고품을 추가했습니다. 그런 다음 중고품을 설치 한 npm install을했습니다. 그런 다음 node NodeServer.js을 사용하여 서버를 실행하려고했습니다. NodeClient.js을 실행하려고해도 비슷한 오류가 발생합니다. 중고품 nodejs 튜토리얼nodejs를 실행할 때 Thrift에 대한 참조가 없습니다. Thrift example

링크 - http://thrift.apache.org/tutorial/nodejs

나는 아래의 관련 명령의 출력을 부착했다. 그것이 나오는 것에 따라

[email protected]:~/git/nodejs-thrift$ ls 
gen-js NodeClient.js NodeServer.js package.json shared.thrift tutorial.thrift 
[email protected]:~/git/nodejs-thrift$ npm install 

> [email protected] install /home/h/git/nodejs-thrift/node_modules/ws 
> (node-gyp rebuild 2> builderror.log) || (exit 0) 

make: Entering directory '/home/h/git/nodejs-thrift/node_modules/ws/build' 
    CXX(target) Release/obj.target/bufferutil/src/bufferutil.o 
bufferutil.target.mk:92: recipe for target 'Release/obj.target/bufferutil/src/bufferutil.o' failed 
make: Leaving directory '/home/h/git/nodejs-thrift/node_modules/ws/build' 
[email protected] /home/h/git/nodejs-thrift 
└─┬ [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    └─┬ [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    └── [email protected] 

npm WARN [email protected] No description 
npm WARN [email protected] No repository field. 
npm WARN [email protected] No license field. 
[email protected]:~/git/nodejs-thrift$ node NodeServer.js 
/home/h/git/nodejs-thrift/gen-js/Calculator.js:384 
Thrift.inherits(CalculatorClient, SharedServiceClient) 
^ 

ReferenceError: Thrift is not defined 
    at Object.<anonymous> (/home/h/git/nodejs-thrift/gen-js/Calculator.js:384:1) 
    at Module._compile (module.js:410:26) 
    at Object.Module._extensions..js (module.js:417:10) 
    at Module.load (module.js:344:32) 
    at Function.Module._load (module.js:301:12) 
    at Module.require (module.js:354:17) 
    at require (internal/module.js:12:17) 
    at Object.<anonymous> (/home/h/git/nodejs-thrift/NodeServer.js:21:18) 
    at Module._compile (module.js:410:26) 
    at Object.Module._extensions..js (module.js:417:10) 
[email protected]:~/git/nodejs-thrift$ 

답변

2

, 나는 js:node 플래그의 js 플래그 instad를 사용하여 내 중고품 파일을 생성하여 실수를했다. 이러한 파일을 생성하는 올바른 방법은 다음과 같습니다.

thrift -r --gen js:node tutorial.thrift 
관련 문제