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

default project template doesn't work with Node v18 #1773

Closed
lhk opened this issue Jan 12, 2023 · 4 comments
Closed

default project template doesn't work with Node v18 #1773

lhk opened this issue Jan 12, 2023 · 4 comments

Comments

@lhk
Copy link

lhk commented Jan 12, 2023

What is the current behaviour?

The default project doesn't work with Node v18.

Steps to Reproduce
I'm following the preactjs getting started guide:

npx preact-cli create default my-project
cd my-project
npm install # this is not necessary I think
npm run dev

This code doesn't run. It results in the error message:

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)

What is the expected behaviour?
It should be possible to use preactjs with an up-to-date version of Node, particularly when following the official tutorial.

Please mention any other relevant information
I think this issue is related: #1579

Please paste the results of npx preact-cli info here.

Environment Info:
  System:
    OS: Linux 6.0 Pop!_OS 22.04 LTS
    CPU: (12) x64 Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
  Binaries:
    Node: 18.12.1 - /usr/bin/node
    npm: 8.12.1 - ~/.npm-global/bin/npm
  Browsers:
    Chrome: 106.0.5249.119
    Firefox: 107.0
  npmPackages:
    preact: ^10.11.3 => 10.11.3 
    preact-cli: ^3.4.2 => 3.4.4 
    preact-render-to-string: ^5.2.6 => 5.2.6 
    preact-router: ^3.2.1 => 3.2.1 
@rschristian
Copy link
Member

rschristian commented Jan 12, 2023

Duplicate of #1643, #1748

Edit: This was a large break in the ecosystem on Node's side, but you can work around this by setting NODE_OPTIONS to use the legacy SSL provider, i.e.,:

{
  "scripts": {
    "dev": "NODE_OPTIONS=--openssl-legacy-provider preact watch"
  }
}

It should be possible to use preactjs with an up-to-date version of Node

preact and preact-cli are two separate entities. Preact itself has no issues here, this is strictly a problem with Preact-CLI.

While we're working on upgrading (as you can see in the issue you linked), it's a lot of work and I'm the only one contributing at the moment. Re:the official guide, we're still debating on what tools we'd like to point to. You might be happier with Vite, Astro, or Fresh.

@rschristian rschristian closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2023
@lhk
Copy link
Author

lhk commented Jan 13, 2023

Thanks for the quick reply and providing a solution.

Regarding the official guide, I think it's very important to have "getting started" instructions that work. By now I assume that most people are on Node v18.x and their first experience with preact will be that the default app template created in the official tutorial raises a strange configuration error. I'd expect that this really harms adoption.

Personally I have a slight preference for Vite. But that really doesn't matter as long as the code runs.

@rschristian
Copy link
Member

rschristian commented Jan 13, 2023

Actually, 18 has very few (comparative) users; most people tend to only upgrade when necessary. I still see a fair number of 10 & 12 users on some projects I maintain.

But indeed, this isn't ideal. I'll try to think up a solution after work but it's a tad finicky as setting that env var can cause issues in a lot of systems, so we don't really want to do it ourselves.

As for the "Getting Started" instructions, I've tried. Can't do much more myself at this point.

Thanks for the feedback and bearing with me.

@rschristian
Copy link
Member

Created #1774 for this.

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

No branches or pull requests

2 participants