Giter Club home page Giter Club logo

Comments (8)

rroylance avatar rroylance commented on May 18, 2024

Hi @tezqa, I see no reason using fs as usual shouldn't work. w3schools has some good and easy to follow and try out examples.

from phaser-ce-npm-webpack-typescript-starter-project.

tezqa avatar tezqa commented on May 18, 2024

Hi @rroylance

I had an error with webpack: Module not found: Error: Cannot resolve module 'fs'

But I solved by adding:

target: 'node',

But now I have a EACCESS error when trying to write my file.

from phaser-ce-npm-webpack-typescript-starter-project.

tezqa avatar tezqa commented on May 18, 2024

Ok forget it, it was because of the path i chose. Thanks :)

from phaser-ce-npm-webpack-typescript-starter-project.

tezqa avatar tezqa commented on May 18, 2024

Hi @rroylance,

I'm trying to access to Electron from the app code in order to get specifics user paths.

import { app } from 'electron'
app.getPath('documents')

But I got undefined when I try to import Electron. Any idea?

from phaser-ce-npm-webpack-typescript-starter-project.

rroylance avatar rroylance commented on May 18, 2024

Hi @tezqa, you may need to require electron rather than importing it.

import app = require('electron'); // or something along these lines

from phaser-ce-npm-webpack-typescript-starter-project.

tezqa avatar tezqa commented on May 18, 2024

I have tried to use require and import, but without success...

Error: Electron failed to install correctly, please delete node_modules/electron and try installing again

It fails because of the node_modules/electron/index.js file:

var pathFile = path.join(__dirname, 'path.txt')

if (fs.existsSync(pathFile)) {
  module.exports = path.join(__dirname, fs.readFileSync(pathFile, 'utf-8'))
} else {
  throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
}

Indeed, __dirname is equal to / when the app is running.

I suppose there is something to configure in the webpack config.

from phaser-ce-npm-webpack-typescript-starter-project.

tezqa avatar tezqa commented on May 18, 2024

Ok I ended up with the Nodejs os module to find the correct path. I don't use Electron.
But it's strange that nobody here needs to use Electron within the app.

from phaser-ce-npm-webpack-typescript-starter-project.

rroylance avatar rroylance commented on May 18, 2024

Hmm. Glad you got it working none the less. Unfortunately I don't even use the electron portion of this project at all so I'm pretty unfamiliar with it.

from phaser-ce-npm-webpack-typescript-starter-project.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.