2017-12-13 16 views
0

"create-react-app"에서 만든 React 프로젝트에 Quickblox를 추가하고 있습니다.Quickblox를 사용할 때 "ReferenceError : Strophe is not defined"

2.7.0 
qbChat.js:22 Uncaught ReferenceError: Strophe is not defined 
    at Object../node_modules/quickblox/src/modules/qbChat.js (qbChat.js:22) 
    at __webpack_require__ (bootstrap 4fbe23e1108d1973a254:678) 
    at fn (bootstrap 4fbe23e1108d1973a254:88) 
    at QuickBlox.init (qbMain.js:51) 
    at Object../src/index.js (index.js:33) 
    at __webpack_require__ (bootstrap 4fbe23e1108d1973a254:678) 
    at fn (bootstrap 4fbe23e1108d1973a254:88) 
    at Object.0 (registerServiceWorker.js:108) 
    at __webpack_require__ (bootstrap 4fbe23e1108d1973a254:678) 
    at bootstrap 4fbe23e1108d1973a254:724 
    at bootstrap 4fbe23e1108d1973a254:724 

ReferenceError: Strophe is not defined 
./node_modules/quickblox/src/modules/qbChat.js 
node_modules/quickblox/src/modules/qbChat.js:22 
    19 | 
    20 | require('strophe.js'); 
    21 | 
> 22 | Strophe.addNamespace('CARBONS', chatUtils.MARKERS.CARBONS); 
    23 | Strophe.addNamespace('CHAT_MARKERS', chatUtils.MARKERS.CHAT); 

그러나 패키지 strope이 실제로 node_modules에 설치됩니다

import QB from 'quickblox'; 

var CREDENTIALS = { 
    appId: 28287, 
    authKey: 'XydaWcf8OO9xhGT', 
    authSecret: 'JZfqTspCvELAmnW' 
}; 

console.log(QB.version); 
QB.init(CREDENTIALS.appId, CREDENTIALS.authKey, CREDENTIALS.authSecret); 

나는 다음과 같은 오류가 발생했습니다. 다음과 같은 설정이 있습니다 :

npm: 5.6.0 

├── [email protected] 
├── [email protected] 
├── [email protected] 
└── [email protected] 

답변

1

npm에서 설치하지 마십시오. 대신,이 같은 quickblox index.html

<script src="%PUBLIC_URL%/quickblox.min.js"></script> 

에서 스크립트 및 액세스 QB을 포함 -

const QB = window.QB; 
QB.init();