Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Failed to find module: "fs" on nativescript #139

Closed
Serge-SDL opened this issue May 15, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@Serge-SDL
Copy link

commented May 15, 2019

Which version are you using?

"@nano-sql/adapter-sqlite-nativescript": "^2.0.1", -> 2.0.1
"@nano-sql/core": "^2.3.1", -> 2.3.1

Describe the bug
I just try to have a quick demo of Nano-SQL on nativescript.:

  • I create a new nativescript-angular project
  • I run: tns plugin add @nano-sql/adapter-sqlite-nativescript
  • I install "@nano-sql/core" manualy (not installed by tns plugin add -> is it normal?)
  • I add a piece of code nSQL().createDatabase({ .... on HomeComponent ngOnInit
  • I run "tns run android" on emulator
    -> I got the error "Failed to find module: "fs", relative to: app/tns_modules/"

The error is related to "nSQL()" part of code: if I just let this code, I still have the issue.

I tried nano-sql on pure angular without any issue yet.

can you help me? thanks!

@ClickSimply

This comment has been minimized.

Copy link
Owner

commented May 17, 2019

I'm working on this and it's proving to be a time consuming problem to fix.

In the short term, it looks like everything should work if you're using a typescript Nativescript project, instead of using the normal javascript project type.

From what I can tell Nativescript is grabbing everything in the module directory and including it, intsead of following the provided require paths like Node/Webpack and literally everything else does.

@Serge-SDL

This comment has been minimized.

Copy link
Author

commented May 20, 2019

Hello,
thanks for your answer!
actually I use Angular Nativescript (with typescript). I tried again to make it work and:

JS: TypeError: nodeFS.readFileSync is not a function
JS: TypeError: nodeFS.readFileSync is not a function
JS: failed to asynchronously prepare wasm: abort({}). Build with -s ASSERTIONS=1 for more info.
JS: abort({}). Build with -s ASSERTIONS=1 for more info.
JS: abort({}). Build with -s ASSERTIONS=1 for more info.
JS: SQLITE.CONSTRUCTOR -  Open DB Error Error: Cannot convert number to Landroid/database/sqlite/SQLiteDatabase$CursorFactory; at index 0
JS: ERROR Error: Uncaught (in promise): abort("abort({}). Build with -s ASSERTIONS=1 for more info."). Build with -s ASSERTIONS=1 for more info.
JS: ERROR Error: Uncaught (in promise): Error: Cannot convert number to Landroid/database/sqlite/SQLiteDatabase$CursorFactory; at index 0

I hope this can help you! I really want to use this plugin in nativescript! :)

@ClickSimply

This comment has been minimized.

Copy link
Owner

commented May 20, 2019

Can you show me your creatDatabase call? This looks like the default “PERM” value is being used instead of the nativescript adapter.

@ClickSimply

This comment has been minimized.

Copy link
Owner

commented May 21, 2019

Just published a new version of the NativeScript adapter.

I found the answer was changing the nSQL import from this:

import { nSQL } from "@nano-sql/core";

To this:

import { nSQL } from "@nano-sql/core/lib/index";

Seems like when you import from the lib path it only includes only the browser safe files instead of requiring the nodeJS dependent path.

Let me know if this takes care of it for you.

@Serge-SDL

This comment has been minimized.

Copy link
Author

commented May 21, 2019

Hey @ClickSimply!
it looks like everything is working! thanks for your reactivity!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.