Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling child_process Cannot read property 'NODE_ENV' of undefined #99

Open
ChuckJonas opened this issue Jul 13, 2018 · 1 comment
Open

Comments

@ChuckJonas
Copy link

ChuckJonas commented Jul 13, 2018

Sorry, new to electron, so I'm probably doing something dumb... but I'm trying to spawn a child process from one of the redux actions just as a test. However, when I add the code:

import { actionCreatorVoid } from './helpers';
import * as process from 'child_process';
export const increment = actionCreatorVoid('INCREMENT_COUNTER');
export const decrement = actionCreatorVoid('DECREMENT_COUNTER');

export function incrementIfOdd() {
  return (dispatch: Function, getState: Function) => {
    const { counter } = getState();


    if (counter % 2 === 0) {
      return;
    }

    var ls = process.spawn('ls');
    console.log(ls);

    dispatch(increment());
  };
}

export function incrementAsync(delay: number = 1000) {
  return (dispatch: Function) => {
    setTimeout(() => {
      dispatch(increment());
    }, delay);
  };
}

i get the following error:

Uncaught TypeError: Cannot read property 'NODE_ENV' of undefined

I see that NODE_ENV is being set using the define plugin, so IDK if this is a bug or maybe what I'm trying to do isn't possible?

Any Insight would be appreciated! (EG if there is a better way/place to do this).

@ChuckJonas ChuckJonas changed the title Calling child_process Calling child_process Cannot read property 'NODE_ENV' of undefined Jul 13, 2018
@hedonicadapter
Copy link

Did you ever figure this out? I'm having the same issue right now

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

No branches or pull requests

2 participants