I'm trying to start a preact project. But the default template created by preact-cli doesn't run. Here's what I did:
npx preact-cli create default my-project
cd my-project
npm install # this is not necessary I think
npm run dev
This results in an 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)
Some versions:
- npx and npm are 8.12.1
- node is v18.12.1
operating system:
Distributor ID: Pop
Description: Pop!_OS 22.04 LTS
Release: 22.04
Codename: jammy
Online version on Stackblitz:
To make the question easier to answer, I created an online example on Stackblitz: https://stackblitz.com/edit/node-zby5qu?file=src%2Findex.js
This works!
As a first attempt at solving my problem, I copied the package-lock.json file from stackblitz to my local machine and reinstalled dependencies. But the problem persists.
So it seems that this is related to my local machine.
Related questions:
This question advises to switch to Node version 16: Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:71:19) And this issue https://github.com/matiasdelellis/facerecognition/issues/613 says that an outdated version of react-scripts can cause the problem.
By now Node 18.13 is the LTS version, I don't want to downgrade to 16. And as far as I can see, I have the latest version of preact-cli. From my package-lock file:
"node_modules/preact-cli": {
"version": "3.4.4",
"resolved": "https://registry.npmjs.org/preact-cli/-/preact-cli-3.4.4.tgz",
The latest version has been published 3 days ago: https://www.npmjs.com/package/preact-cli?activeTab=readme