Node 'fs' issue

Hi,

I installed fs in my app by using this commnad

npm install fs --save

and in my model take reference of fs like

import * as fs from ‘fs’;

error is:

Couild not fine module ‘fs’ imported from 'testapp/models/testmodel

how can i resolve this issue

Node is service-side javascript, so you shouldn’t use it in an Ember model (or any other Ember module).

Also Node uses CommenJS moduling, so import shouldn’t work anyway.

try this plug-in https://github.com/ef4/ember-auto-import

ember-auto-import isn’t going to help with this, because fs is not something that can ever work directly from within a web browser. Ember apps run in web browsers, web browsers can’t manipulate the filesystem.

One thing you can do is use ember-electron to package your ember app into a desktop app, in which case you can use fs and everything else Node can do.

@ef4 You mentioned, " One thing you can do is use ember-electron to package your ember app into a desktop app, in which case you can use fs and everything else Node can do."

Is there anywhere that you know of that goes into any details about how you might approach this?

Start with https://ember-electron.js.org and ask questions in the #topic-desktop channel on the Ember Discord.