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

[Server crash error] running README example #12

Closed
hbrunie opened this issue Jan 19, 2022 · 4 comments
Closed

[Server crash error] running README example #12

hbrunie opened this issue Jan 19, 2022 · 4 comments

Comments

@hbrunie
Copy link

hbrunie commented Jan 19, 2022

Hi,

Trying the example in README.md

git clone git@github.com:elix/react-example.git
cd react-example
npm install
npm run build
npx http-server

I got an error which made my local server stop running:

 >> npx http-server
npx: installed 39 in 3.24s
Starting up http-server, serving ./

http-server version: 14.1.0

http-server settings: 
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
  http://127.0.0.1:8080
  http://194.199.25.74:8080
Hit CTRL-C to stop the server

[Wed Jan 19 2022 10:13:00 GMT+0100 (Central European Standard Time)]  "GET /" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0"
_http_outgoing.js:470
    throw new ERR_HTTP_HEADERS_SENT('set');
    ^

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:470:11)
    at module.exports.ResponseStream.(anonymous function) [as setHeader] (/home/hbrunie/.npm/_npx/183919/lib/node_modules/http-server/node_modules/union/lib/response-stream.js:100:34)
    at Object.exports.(anonymous function) (/home/hbrunie/.npm/_npx/183919/lib/node_modules/http-server/lib/core/status-handlers.js:57:7)
    at Readable.stream.on (/home/hbrunie/.npm/_npx/183919/lib/node_modules/http-server/lib/core/index.js:339:22)
    at Readable.emit (events.js:198:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

I am new to programming in js, could you give me any help to correct my misuse of the framework?

Thanks,
Best,
Hugo

@JanMiksovsky
Copy link
Member

The react-example template is quite old, so it was depending a number of old versions of other projects.

I've updated the dependencies, which fixed the problem for me. Please give that a try and let me know if things now work for you.

BTW the React project is finally — years later — moving towards supporting web components natively. When that's released, it will be easier to use web components like Elix's in React apps.

@hbrunie
Copy link
Author

hbrunie commented Jan 19, 2022

I have pulled the dependencies update but this does not fix the problem on my computer.

[Wed Jan 19 2022 20:15:31 GMT+0100 (Central European Standard Time)]  "GET /" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0"
_http_outgoing.js:470
    throw new ERR_HTTP_HEADERS_SENT('set');
    ^

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:470:11)
    at module.exports.ResponseStream.(anonymous function) [as setHeader] (/home/hbrunie/.npm/_npx/241435/lib/node_modules/http-server/node_modules/union/lib/response-stream.js:100:34)
    at Object.exports.(anonymous function) (/home/hbrunie/.npm/_npx/241435/lib/node_modules/http-server/lib/core/status-handlers.js:57:7)
    at Readable.stream.on (/home/hbrunie/.npm/_npx/241435/lib/node_modules/http-server/lib/core/index.js:339:22)
    at Readable.emit (events.js:198:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

@JanMiksovsky
Copy link
Member

I can run the react-example demo without issues with http-server on two different machines running different OSes. The example also works with another server (Apache). So my best guess at this point is that this isn't a problem with Elix or the react-example demo.

Some searching revealed http-party/http-server#756, which may be the problem you're seeing. That issue suggests the problem may be trying to use http-server with older versions of Node. I'm running Node 17.3. Perhaps upgrading Node will help?

@hbrunie
Copy link
Author

hbrunie commented Jan 20, 2022

Thank you for searching on my problem!
This solved it, I just had to update my Node version from v10.19.0 to v16.13.2
on my Ubuntu 20 with the command lines (for the record):

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

found on askubuntu.com (https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version)

Thanks,
Best,
Hugo

@hbrunie hbrunie closed this as completed Jan 20, 2022
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