0
votes

i'm trying to use the localstorage NativeScript module located at

https://www.npmjs.com/package/nativescript-localstorage

I have a LocalStorage service coppied from a web app that I want to use with a NativeScript app, I installed the module successfully with tns plugin add nativescript-localstorage. The first thing i'm confused about is: My app is written in Typescript and this module is written in Javascript would I be able to import/use this module in my app? I added the following to the imports section of my LocalStorageService: var localStorage = require('nativescript-localstorage'); The app built fine but after it got deployed I got the following error:

error: Error: com.tns.NativeScriptException: Failed to find module: "nativescript-localstorage", relative to: app/tns_modules/

Then I tried: import * as localStorage from 'nativescript-localstorage'; I then get a error saying cannot find module nativescript-localstorage. Any idea what i'm doing wrong?

1

1 Answers

1
votes

That error is not related to the way you import it, rather the fact your platforms/[platform]/[appname]/app/tns_modules folder doesn't include the plugin. Just tns platform remove [platform], tns platform add [platform] and tns run [platform] and you should see it. And be able to require it.