Git Product home page Git Product logo

electron-typescript-react-quick-start's People

Contributors

claudioc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

electron-typescript-react-quick-start's Issues

Node core modules with RequireJs

I have been trying to import "child_process" inside of my electron-aurelia project but with no success. So far I have tryied

const ChildProcess = require('child_process');

and

import * as ChildProcess for "child_process"

but none of the above work. The first one returns the following error:

Error: Module name "child_process" has not been loaded yet for context

and the second returns error:

Failed to load resource: net::ERR_FILE_NOT_FOUND child_process.js

Can anybody help me with this issue?
Thank you

Trouble with importing node/electron modules like 'fs' on rendering thread

Hello Claudio, thanks very much for this "quick start". It was quick to set up but I have hit a roadblock quite quickly afterwards. If this question has an obvious answer, please excuse me as I am pretty now to a lot of these technologies.

I want to make an electron app which accesses the file system. At first I assumed that the file access would have to be from the main thread and the render thread would have to talk to the main thread through "remote" or "ipc". But later I read that the rendering thread can use the node "fs" library to access the filesystem directly.

I have tried both of these options, and I'm basically coming up against the same problem, which is that I don't know how to get the browser to find the right libraries when they are not part of the node_modules directory.

If I try adding a line like import fs from 'fs'; in hello-world.tsx, the Typescript compiles fine but when I run the application, the chrome devtools window gives an error like this:

Failed to load resource: net::ERR_FILE_NOT_FOUND
Error: (SystemJS) XHR error loading file:///D:/Mike/Dev/mike-electron-typescript-react/dist/fs(…)

I notice that in your index.html, you do the following to make SystemJS able to know where the React and ReactDOM libraries are found,

System.config({
            map: {
                'react': '../node_modules/react/dist/react.js',
                'react-dom': '../node_modules/react-dom/dist/react-dom.js'
            },

So my first instinct was to add another like that is like these, until I realized that 'fs' is not present in node_modules. From what I understand now, you don't need to "npm install" fs because it is part of node's core modules. But then it's not clear to me what the right move is to get SystemJS to find it.

I read a couple of threads like these two:
systemjs/systemjs#124 ("Can't load Node core modules")
aurelia/skeleton-navigation#537 ("Accessing Node core modules from within an Aurelia Electron App")

but both discussions have a lot of back and forth, some other things that cloud the discussion, and if there was a conclusion to them, it was not clear what it was or how to apply it.

So I'm just wondering if you have a simple answer to this problem of how to import fs into one of the renderer-side tsx files.

I encountered basically the same problem before I discovered that fs could be used from the render thread, where I was trying to use "electron.ipcrenderer" but then failiing to be able to load "electron" in a similar way and not being able to figure out what the appropriate thing to add to the systemjs configuration was.

Any help is appreciated!

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.