Giter VIP home page Giter VIP logo

Comments (6)

lee-zhg avatar lee-zhg commented on July 30, 2024

Hi Coord,

I am having the exact same issue. What code changes did you make to run the demo? After I simply switch to "exec" from "spawn" and define "exec", it still fails. Appreciate if you could shed more light.

const exec = require('child_process').exec;

const client = exec('./node_modules/.bin/react-scripts', ['start'], {
  env: Object.assign({}, process.env, {
    REACT_APP_SERVER: 'http://localhost:5000',
  }),
  stdio: 'inherit',
});

Thanks
Lee

from discovery-nodejs.

Coord avatar Coord commented on July 30, 2024

Hi Lee,

Here is my updated start.js file:

const exec = require('child_process').exec;
const server = require('../server');

const client = exec(__dirname + '/../node_modules/.bin/react-scripts start', {
  env: Object.assign({}, process.env, {
    REACT_APP_SERVER: 'http://localhost:5000',
  })
}, (error, stdout, stderr) => {
  if (error) {
    // eslint-disable-next-line no-console
    console.log(`ERROR: ${error}`);
    killServer(() => {
      process.exit(1);
    });
    return;
  }
  console.log(`stdout: ${stdout}`);
  console.log(`stderr: ${stderr}`);
});

function killServer(callback) {
  const ppid = server.pid;
  const killer = exec('pkill -9 -P ' + ppid);

  killer.on('exit', () => {
    // eslint-disable-next-line no-console
    console.log(`PPID ${ppid} killed`);

    if (callback) {
      callback();
    }
  });
}

I also had to change one of the script commands in package.json to make it work correctly:

"build": "./node_modules/.bin/react-scripts build"

I did these changes relatively quickly, so it may be a little hacky. Let me know if you find a better solution :)

from discovery-nodejs.

lee-zhg avatar lee-zhg commented on July 30, 2024

Thank you, Coord,

from discovery-nodejs.

germanattanasio avatar germanattanasio commented on July 30, 2024

@maniax89 do you think you can take a look at this? @Coord sent me an email and I think this is one of the changes your team did to adopt create-react-app

from discovery-nodejs.

maniax89 avatar maniax89 commented on July 30, 2024

I have made a fix in #91 and it should work cross-platform now (sorry about that)

as for appending the ./node_modules/.bin -> I have removed this from all code as any script run with npm run supposedly adds the ./node_modules/.bin to the $PATH , thus we should never need to include it in scripts.

Let us know if you still have issues

from discovery-nodejs.

watson-github-bot avatar watson-github-bot commented on July 30, 2024

🎉 This issue has been resolved in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from discovery-nodejs.

Related Issues (12)

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.