1
votes

I tried to use lib as per the nativescript documentation, but when I try to use it there is an error that I can't solve besides some modules like net and tls it can't find it automatically. After using npm install to put tls and net I can't solve this problem 'TypeError: Cannot read property' browser 'of undefined' and I don't know how to solve this problem, to test if lib was working normally I tried using ionic 4 and it worked normally but in nativescript I found this problem in both Angular and 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.
1

1 Answers

2
votes

Its good to see people using the typescript client. Unfortunately, we don't directly support NativeScript and it appears that our DefaultRESTClient imports something that NativeScript doesn't support.

To fix this on your own you will need to use webpack to override the DefaultRESTClient with a custom implementation that is compatible with NativeScript or override the cross-fetch package that is used inside DefaultRESTClient with something that provides the fetch api for NativeScript.

You can also open a ticket on our Github for TypeScript suggesting that NativeScript is something you would like supported and we will complete it if it gets enough up votes or seems like something important we should support.