I know that Angular 2 runs in a web browser that does not have access to the file system.
However, I use Electron as my front-end, and also run the application via electron:
"build-electron": "ng build --base-href . && cp src/electron/* dist",
"electron": "npm run build-electron && electron dist"
So I run it with the help npm run electronthat works at the very end electron dist.
Since I run electron, and not ng, I think I should have access to the file system. However, when I do this:
import * as fs from 'fs'
I get an error message:
ng:///AppModule/AppComponent_Host.ngfactory.js:5 ERROR TypeError: __WEBPACK_IMPORTED_MODULE_0_fs__.readFileSync is not a function(…)
Similarly, when I try: var fs = require('fs');
I get:
ng:///AppModule/AppComponent_Host.ngfactory.js:5 ERROR TypeError: fs.readFileSync is not a function
This is the call causing the error:
this.config = ini.parse(fs.readFileSync('../../CONFIG.ini', 'utf-8'))
Does anyone know what that means?
Thank.
source
share