1

ネイティブスクリプトのドキュメントに従ってlibを使用しようとしましたが、使用しようとすると、netやtlsなどの一部のモジュール以外に解決できないエラーが発生し、自動的に見つけることができません。npm install を使用して tls と net を配置した後、この問題を解決できません 'TypeError: Cannot read property' browser 'of undefined' で、この問題を解決する方法がわかりません。lib が正常に動作しているかどうかをテストするために、使用してみましたionic 4 で正常に動作しましたが、nativescript では Angular と Vue の両方でこの問題が見つかりました。

Webpack compilation complete. Watching for file changes.
Webpack build done!
Successfully synced application org.nativescript.studyLogin on device 0aa24655.
Successfully transferred bundle.292d892ab2d871e6a00e.hot-update.js on device 0aa24655.
Successfully transferred 292d892ab2d871e6a00e.hot-update.json on device 0aa24655.
Successfully transferred bundle.js on device 0aa24655.
Successfully transferred runtime.js on device 0aa24655.
Successfully transferred vendor.js on device 0aa24655.
Restarting application on device 0aa24655...
Successfully synced application org.nativescript.studyLogin on device 0aa24655.
Successfully transferred bundle.e980eda364519dbb87a0.hot-update.js on device 0aa24655.
Successfully transferred e980eda364519dbb87a0.hot-update.json on device 0aa24655.
Refreshing application on device 0aa24655...
ActivityManager: Permission Denial: getCurrentUser() from pid=2971, uid=10187 requires android.permission.INTERACT_ACROSS_USERS
System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function 
System.err: TypeError: Cannot read property 'browser' of undefined
System.err: File: (file:///node_modules/pbkdf2/lib/default-encoding.js:3:11)
System.err: StackTrace: 
System.err:     ../node_modules/pbkdf2/lib/default-encoding.js(file:///node_modules/pbkdf2/lib/default-encoding.js:3:11)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/pbkdf2/lib/sync.js(file:///node_modules/pbkdf2/lib/sync.js:14:22)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/pbkdf2/index.js(file:///node_modules/pbkdf2/index.js:24:23)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/crypto-browserify/index.js(file:///node_modules/crypto-browserify/index.js:14:8)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/request/lib/helpers.js(file:///node_modules/request/lib/helpers.js:4:13)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/request/index.js(file:///node_modules/request/index.js:19:14)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/@fusionauth/typescript-client/build/src/DefaultRESTClient.js(file:///node_modules/@fusionauth/typescript-client/build/src/DefaultRESTClient.js:19:14)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/@fusionauth/typescript-client/build/src/DefaultRESTClientBuilder.js(file:///node_modules/@fusionauth/typescript-client/build/src/DefaultRESTClientBuilder.js:18:28)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/@fusionauth/typescript-client/build/src/FusionAuthClient.js(file:///node_modules/@fusionauth/typescript-client/build/src/FusionAuthClient.js:18:35)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/@fusionauth/typescript-client/build/index.js(file:///node_modules/@fusionauth/typescript-client/build/index.js:21:9)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ./app/lib/fusionAuthClientInstance.ts(file:///src/app/lib/fusionAuthClientInstance.ts:1:0)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ./app/item/items.component.ts(file:///src/app/item/items.component.ts:1:0)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ./app/app-routing.module.ts(file:///src/app/app-routing.module.ts:1:0)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ./app/app.module.ts(file:///src/app/app.module.ts:1:0)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at (file:///data/data/org.nativescript.studyLogin/files/app/bundle.js:490:73)
System.err:     at ./main.ts(file:///data/data/org.nativescript.studyLogin/files/app/bundle.js:560:30)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at checkDeferredModules(file:///src/webpack/bootstrap:43:0)
System.err:     at webpackJsonpCallback(file:///src/webpack/bootstrap:30:0)
System.err:     at (file:///data/data/org.nativescript.studyLogin/files/app/bundle.js:2:57)
System.err:     at require(:1:266)
System.err: TypeError: Cannot read property 'browser' of undefined
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function 
System.err: TypeError: Cannot read property 'browser' of undefined
System.err: File: (file:///node_modules/pbkdf2/lib/default-encoding.js:3:11)
System.err: StackTrace: 
System.err:     ../node_modules/pbkdf2/lib/default-encoding.js(file:///node_modules/pbkdf2/lib/default-encoding.js:3:11)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/pbkdf2/lib/sync.js(file:///node_modules/pbkdf2/lib/sync.js:14:22)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/pbkdf2/index.js(file:///node_modules/pbkdf2/index.js:24:23)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/crypto-browserify/index.js(file:///node_modules/crypto-browserify/index.js:14:8)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/request/lib/helpers.js(file:///node_modules/request/lib/helpers.js:4:13)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/request/index.js(file:///node_modules/request/index.js:19:14)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/@fusionauth/typescript-client/build/src/DefaultRESTClient.js(file:///node_modules/@fusionauth/typescript-client/build/src/DefaultRESTClient.js:19:14)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/@fusionauth/typescript-client/build/src/DefaultRESTClientBuilder.js(file:///node_modules/@fusionauth/typescript-client/build/src/DefaultRESTClientBuilder.js:18:28)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/@fusionauth/typescript-client/build/src/FusionAuthClient.js(file:///node_modules/@fusionauth/typescript-client/build/src/FusionAuthClient.js:18:35)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/@fusionauth/typescript-client/build/index.js(file:///node_modules/@fusionauth/typescript-client/build/index.js:21:9)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ./app/lib/fusionAuthClientInstance.ts(file:///src/app/lib/fusionAuthClientInstance.ts:1:0)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ./app/item/items.component.ts(file:///src/app/item/items.component.ts:1:0)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ./app/app-routing.module.ts(file:///src/app/app-routing.module.ts:1:0)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ./app/app.module.ts(file:///src/app/app.module.ts:1:0)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at (file:///data/data/org.nativescript.studyLogin/files/app/bundle.js:490:73)
System.err:     at ./main.ts(file:///data/data/org.nativescript.studyLogin/files/app/bundle.js:560:30)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at checkDeferredModules(file:///src/webpack/bootstrap:43:0)
System.err:     at webpackJsonpCallback(file:///src/webpack/bootstrap:30:0)
System.err:     at (file:///data/data/org.nativescript.studyLogin/files/app/bundle.js:2:57)
System.err:     at require(:1:266)
System.err: TypeError: Cannot read property 'browser' of undefined
System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4705)
System.err:     at android.app.ActivityThread.access$1400(ActivityThread.java:168)
System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1389)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
System.err:     at android.os.Looper.loop(Looper.java:176)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:5493)
System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
System.err:     at java.lang.reflect.Method.invoke(Method.java:525)
System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1225)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1041)
System.err:     at dalvik.system.NativeStart.main(Native Method)
System.err: Caused by: com.tns.NativeScriptException: Error calling module function 
System.err: TypeError: Cannot read property 'browser' of undefined
System.err: File: (file:///node_modules/pbkdf2/lib/default-encoding.js:3:11)
System.err: StackTrace: 
System.err:     ../node_modules/pbkdf2/lib/default-encoding.js(file:///node_modules/pbkdf2/lib/default-encoding.js:3:11)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/pbkdf2/lib/sync.js(file:///node_modules/pbkdf2/lib/sync.js:14:22)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/pbkdf2/index.js(file:///node_modules/pbkdf2/index.js:24:23)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/crypto-browserify/index.js(file:///node_modules/crypto-browserify/index.js:14:8)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/request/lib/helpers.js(file:///node_modules/request/lib/helpers.js:4:13)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/request/index.js(file:///node_modules/request/index.js:19:14)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/@fusionauth/typescript-client/build/src/DefaultRESTClient.js(file:///node_modules/@fusionauth/typescript-client/build/src/DefaultRESTClient.js:19:14)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/@fusionauth/typescript-client/build/src/DefaultRESTClientBuilder.js(file:///node_modules/@fusionauth/typescript-client/build/src/DefaultRESTClientBuilder.js:18:28)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/@fusionauth/typescript-client/build/src/FusionAuthClient.js(file:///node_modules/@fusionauth/typescript-client/build/src/FusionAuthClient.js:18:35)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ../node_modules/@fusionauth/typescript-client/build/index.js(file:///node_modules/@fusionauth/typescript-client/build/index.js:21:9)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ./app/lib/fusionAuthClientInstance.ts(file:///src/app/lib/fusionAuthClientInstance.ts:1:0)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ./app/item/items.component.ts(file:///src/app/item/items.component.ts:1:0)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ./app/app-routing.module.ts(file:///src/app/app-routing.module.ts:1:0)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at ./app/app.module.ts(file:///src/app/app.module.ts:1:0)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at fn(file:///src/webpack/bootstrap:120:0)
System.err:     at (file:///data/data/org.nativescript.studyLogin/files/app/bundle.js:490:73)
System.err:     at ./main.ts(file:///data/data/org.nativescript.studyLogin/files/app/bundle.js:560:30)
System.err:     at __webpack_require__(file:///src/webpack/bootstrap:750:0)
System.err:     at checkDeferredModules(file:///src/webpack/bootstrap:43:0)
System.err:     at webpackJsonpCallback(file:///src/webpack/bootstrap:30:0)
System.err:     at (file:///data/data/org.nativescript.studyLogin/files/app/bundle.js:2:57)
System.err:     at require(:1:266)
System.err: TypeError: Cannot read property 'browser' of undefined
System.err:     at com.tns.Runtime.runModule(Native Method)
System.err:     at com.tns.Runtime.runModule(Runtime.java:662)
System.err:     at com.tns.Runtime.run(Runtime.java:654)
System.err:     at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
System.err:     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4702)
System.err:     ... 10 more
ActivityManager: Process org.nativescript.studyLogin (pid 2971) (adj 0) has died.
Successfully synced application org.nativescript.studyLogin on device 0aa24655.
4

1 に答える 1

2

typescript クライアントを使用している人を見るのは良いことです。残念ながら、NativeScript を直接サポートしておらず、DefaultRESTClient が NativeScript がサポートしていないものをインポートしているようです。

これを自分で修正するには、webpack を使用してDefaultRESTClient、NativeScript と互換性のあるカスタム実装で をオーバーライドするか、cross-fetch内部で使用されるパッケージをNativeScriptDefaultRESTClientの API を提供するものでオーバーライドする必要がありますfetch

また、 TypeScriptの Github でチケットを開いて、NativeScript をサポートしたいことを提案してください。十分な投票数が得られた場合、またはサポートすべき重要なもののように思われる場合は、それを完了します。

于 2019-10-09T16:08:24.037 に答える