Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

node binding is loaded into the electron browser #54

Open
alexisvincent opened this issue Jul 21, 2016 · 12 comments
Open

node binding is loaded into the electron browser #54

alexisvincent opened this issue Jul 21, 2016 · 12 comments

Comments

@alexisvincent
Copy link

When spawning an electron window, systemjs-babel-node.js is loaded instead of systemjs-babel-browser.js. Think this is because the environment is being detected as node instead of browser.

@alexisvincent
Copy link
Author

Specifically this error is thrown

undefined:1 Uncaught (in promise) Error: (SystemJS) http://localhost:3000/jspm_packages/npm/[email protected]/systemjs-babel-node.js:26786
      var terminator = argv.indexOf('--');
                           ^
    TypeError: Cannot read property 'indexOf' of undefined

@alexisvincent
Copy link
Author

@guybedford can get around with

SystemJS.config({
  "packages": {
    "npm:[email protected]": {
      map: {
        "systemjs-babel-build": "./systemjs-babel-browser.js",
      }
    }
  }
});

But then hit an issue with process not being defined

@guybedford
Copy link
Member

Is the process error in this file - https://github.com/jspm/nodelibs-process/blob/master/process-node.js?

@guybedford
Copy link
Member

What version of Node are you using?

@alexisvincent
Copy link
Author

undefined:1 Uncaught (in promise) Error: (SystemJS) http://localhost:3000/jspm_packages/github/jspm/[email protected]/process-node.js:3
    var pEnv = process.env;
                      ^
    TypeError: Cannot read property 'env' of undefined

@alexisvincent
Copy link
Author

which is strange, because when I evaluate window.process i get an object back

@alexisvincent
Copy link
Author

v6.3.0 however I think issue is on v5 as well, let me check

@alexisvincent
Copy link
Author

Yep, same issue on v5.2.0

@guybedford
Copy link
Member

You can also check the value of System.import('@node/process').then(function(m) { var process = m.default })... which should be the process object, and if not that is a SystemJS bug in Electron.

@alexisvincent
Copy link
Author

Uncaught (in promise) TypeError: Cannot read property 'default' of undefined

@alexisvincent
Copy link
Author

I hope this isn't my setup. I took an existing JSPM 17 app, and just put it in electron. Checked it and it works outside of electron via the same port

@guybedford
Copy link
Member

@alexisvincent I just ran the electron quickstart app and then did System.import('@node/process').then(console.log.bind(console)) and am definitely seeing the right process logged. What mode would I need to run Electron in to reproduce this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants