0

I tested with a simple app generated by

npx create-react-app myfirstreact

It works fine with

npm start

but if I try to run it in the background with

   nohup npm start &

I get

Starting the development server...

events.js:174 throw er; // Unhandled 'error' event ^

Error: EBADF: bad file descriptor, read Emitted 'error' event at: at lazyFs.read (internal/fs/streams.js:165:12) at FSReqWrap.wrapper [as oncomplete] (fs.js:467:17) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! myfirstreact@0.1.0 start: react-scripts start npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the myfirstreact@0.1.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR!
/home/jglickman/.npm/_logs/2020-10-06T04_43_39_480Z-debug.log

  • Have you tried solutions provided here: https://stackoverflow.com/questions/16604176/error-ebadf-bad-file-descriptor-when-running-node-using-nohup-of-forever – AhmerMH Oct 06 '20 at 05:09
  • Hi. Thank you for your reply. I tried them just now. The accepted solution I thin kdoesn't apply to me, since this simple app only uses imports. Would I need to put __dirname on the imports? Here are some of my other attempts: jglickman@devapp01:~/git/test/myfirstreact$ node src/App.js /home/jglickman/git/test/myfirstreact/src/App.js:1 import React from 'react'; ^^^^^ SyntaxError: Unexpected identifier – Joshua Glickman Oct 07 '20 at 07:05
  • Did you tried other solutions? like running in parenthesis and running it like `nohup node server.js – AhmerMH Oct 08 '20 at 03:40
  • Hi. Here are the results: `joshua@joshua-KVM:~/git/test/myfirstreact$ node server.js internal/modules/cjs/loader.js:638 throw err; ^ Error: Cannot find module '/home/joshua/git/test/myfirstreact/server.js' joshua@joshua-KVM:~/git/test/myfirstreact$ cd src joshua@joshua-KVM:~/git/test/myfirstreact/src$ node server.js internal/modules/cjs/loader.js:638 throw err; ^ Error: Cannot find module '/home/joshua/git/test/myfirstreact/src/server.js' ` – Joshua Glickman Oct 11 '20 at 02:52
  • I believe this is because there is no such file as server.js :) – Joshua Glickman Oct 11 '20 at 02:53
  • I figured out that I needed to run nohup node scripts/start.js & then that error no longer happens. Ty. If you put this as an answer, I will accept it. I think it's because the server accepts keyboard input – Joshua Glickman Oct 17 '20 at 06:45

1 Answers1

0

Try running it like this:

nohup node scripts/start.js  

I think this post will help too.

AhmerMH
  • 638
  • 7
  • 18