Using electron with ionic2, i cant access filesystem options on windows using
Const fs = require(‘fs’);
Keeps throwing error : fs.exists is not a function
Using electron with ionic2, i cant access filesystem options on windows using
Const fs = require(‘fs’);
Keeps throwing error : fs.exists is not a function
In this case, you’ll need to run
npm install @types/node
Since fs is part of the node API, you need the extra types.
Then you can do
import { readFileSync} from 'fs';
or any of the methods from fs
Thank a lot and great job with ionic2 2.00 release. but it still isnt workng
@types/node is installed
declare var require: any
const fs = require(“fs”);
fs.readFileSync(’.’);
error: TypeError: fs.readFileSync is not a function
am i missing something
i did to my understanding.
i installed @types/node
if i import { readFileSync} from ‘fs’; how am i to use it
the method in the node docs is fs.readFileSync().
i dont know
Once you’ve imported it, can’t you just call it as readFileSync()
? Webpack should handle gluing it together.
Tried it but not working. i am getting
TypeError: webpack_require.i(…) is not a function
thanks.
still same error
Gotten it to work
added this to index.html
<script const fs = require("fs"); </script then declare var fs: any; in .ts file ThanksThat import statement imports only the readFileSync function, not the entire fs module, so you can use the function directly as readFileSync('.');
(without the fs. part)