2017-03-18 7 views
0

Electron 내에서 실행되는 Angular CLI 프로젝트가 있습니다. 내 구성 요소 중 하나에 @pokusew/pcsclite을 가져 와서 NFC 기능을 사용하려고합니다. 나는 import * as pcsclite from "../../node_modules/@pokusew/pcsclite"을 사용하여 라이브러리를 가져옵니다. 내가 this.pcsc = pcsclite()를 호출하면 그러나, 나는 콘솔에 다음과 같은 오류가 발생합니다 :Angular2/Electron에서 @ pokusew/pcsclite 가져 오기 TypeError

TypeError: exists is not a function

그리고 빌드 과정 :

WARNING in ./~/bindings.js

Critical dependency: the request of a dependency is an expression

+0

갱신 오류 및 최소 코드의 스크린 샷과 함께 게시 할 수 있습니다. 또한 묻기 전에 [** this **] (http://stackoverflow.com/help/how-to-ask)를보십시오. – Aravind

답변

0

TypeError: exists is not a function는 노드 바인딩 모듈에서 버그가 수 있도록 나타납니다. 참조 : https://github.com/TooTallNate/node-bindings/pull/20

새 릴리스가 NPM에서 사용 가능할 때 수정해야합니다.

그러나 AngularCLI/Webpack을 사용할 때 한 단계 더 나아가이 수정으로도 @pokusew/pcsclite이 작동하지 않습니다. 이 설정에서 작동 시키려면 @pokusew/pcsclitenode-bindings 대신 node-loader을 사용해야 바인딩 파일을로드 할 수 있습니다. 이 같은 로컬로 변경할 수 있습니다

편집 "/node_modules/@pokusew/pcsclite/package.json"

"dependencies": { 
    "bindings": "github:tootallnate/node-bindings#pull/20/head", < Instead of this, 
    "node-loader": "^0.6.0", << use this 
    "nan": "^2.5.1" 
}, 

다음 편집 "/node_modules/@pokusew/pcsclite/lib/pcsclite.js을 "

const pcsclite = require('node-loader!./../build/Release/pcsclite.node');