Skip to content

(reading files issue) ENOENT: no such file or dicrectory - fs:js.640 #6911

@chito256

Description

@chito256
  • Electron version: 1.3.3
  • Operating system: Ubuntu Linux 16.04 LTS

Hi, I am trying to read a json file using NodeJS's fs module. The path is correct, but when the app runs, it could not find the file.

Here is the block of code in a file called index.js:

// index.js
const fs = window.require('fs');
const path = window.require('path');

// get configuration file
const data = fs.readFileSync(path.join(__dirname, 'config.json'), 'utf8');
const config = JSON.parse(data);

Here is my app's structure:
screenshot from 2016-08-20 19-58-49

The BrowserWindow then responded with this:
screenshot from 2016-08-20 20-00-59

fs:js.640 then pointed to this:
screenshot from 2016-08-20 20-03-09

I know this sounds like a problem with NodeJS, but I got the same code working outside of the app.
I hope this can be fixed, thanks in advance! :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions