[ts] property 'file' doesnot exist in the file cordova ionic 2

Hi,
I am trying to use the ‘File’ Api that allow read and write acess to the file. I have a created a new project with tutorial template. It create a typescript project. I tried to create the js project using --no-ts flag but it doesn’t work. So I decided to check with the typescript.
When I tried to do
alert("temp directory" + cordova.file.tempDirectory );
I get the error [ts]cannot find name cordova.Then I run the command

npm install -g typings
typings install dt~cordova --save --global

it remove the cannot find cordova error but now it is showing error with file, ([ts] ‘file’ doesnot exist in the file cordova )
I googled and didn’t find the solution for this.
Please let me if any one has faced the similar issue and let me how can I fix this issue.
I am not sure why ionic has removed js. It is working with js project. There is no way to create js project now.
It will be very difficult for the developer like me who don’t know typescript. :disappointed:

Ionic does not support creating regular ES6 projects anymore.

If you need to use the fiel plugin, you can use ionic-native, which not only provides the proper type information and autocompletion, but handles any async data.

Using ionic native also makes it so you don’t have to deal with typings for the plugins it supports.

Hi,

I have checked the ionic-native for File but I didn’t find the way to get the file path of the app.
How can I can get the phone memory location and sdcard location?
Could you please suggest me the best location to save the file so that it works both for android and ios.

try this:
typings install dt~cordova/plugins/filesystem --global --save

Hi,
I got the same exact problem of @Shresthabk. I tried doing suggestion of @mhartington for using it, but it didn’t work also for me.

Maybe I have to find the way out Ionic 2 and turn back to Ionic 1, maybe.

to make this work you must this line declare var cordova: any; right after the imports not inside the class

i was having this issue and cant believe this is still true as of Ionic4

building on Ionic 5.2.7 and this still hasn’t been fixed, wow :roll_eyes: