06-08-2021 11:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-08-2021 11:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
In all my apps and watch faces when accessing file system I've always used import * as fs from 'fs' and it worked fine. However during the current development I encountered an error "App: Unhandled exception: TypeError: Expected a function". I pinpointed it to FS module. Turns out FS module returns an object named 'default' and now to access any method I need to specify it as fs.default (eg. fs.default.writeFileSync). I don't understand why it's happening. To be on a safe side I created a fail-safe to switch to the 'fs.default' object if fs is unavailable. I installed the watch face on my Ionic and it sure enough does select fs.default instead of good old fs. I'm really confused as in other apps it still works as API documentation specifies (all methods are directly on fs).
Has anyone seen this issue before?
06-08-2021 14:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


06-08-2021 14:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I don't know what I'm talking about, but I think there might have been a recent change in the build process that is more stringent in the way that things are imported. It's possible that reverting to a previous SDK version might avoid the issue.
Gondwana Software

06-08-2021 14:59
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-08-2021 14:59
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I'm actually using SDK 4.2.0... I did check the SDK 5 and it seems like that one supports both: 'fs' and 'fs.default'. Really strange behavior.

08-05-2021 19:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-05-2021 19:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hello @ThorgalA! Try changing to
import fs from 'fs'
In now the new version 4.3.0
If this answer works please mark this post as a Best Answer. ~ K.K Designs
