npm install -g preact-clipreact create <app> --yarncd <app>yarn serveSetting up SSL certificate (may require sudo)...
INFO: Could not find files for the given pattern(s).
Attempting to spawn simplehttp2server to generate cert.
Failed to generate dev SSL certificate: Error: spawn C:\<app_dir>\node_modules\simplehttp2server\vendor\simplehttp2server_windows_amd64.exe ENOENT
Falling back to shared directory + simplehttp2server.
(dir: C:\Users\<username>\AppData\Roaming\preact-cli)
server error> Error: spawn C:\<app_dir>\node_modules\simplehttp2server\vendor\simplehttp2server_windows_amd64.exe ENOENT
Error: spawn C:\<app_dir>\node_modules\simplehttp2server\vendor\simplehttp2server_windows_amd64.exe ENOENT
OS: Windows 10 x64
Terminal: Powershell (Administrator mode) (PSVersion: 5.1.14393.1480)
Hi. ENOENT means there is no such file. Could you run yarn install inside your project folder again to make sure everything get installed?
I'm fairly certain the file exists...I can navigate to it in a terminal (and an Explorer window). Did a yarn install just to be sure.
Also, I think the simplehttp2server is not the only issue here. The devcert library is also failing to generate the SSL certificates.
I have the same problem and copy pasting the ENOENT file in powershell and executing it works
PS F:\sources\Node\my-preact> npm run serve
[email protected] serve F:\sources\Node\my-preact
preact build && preact serve
Build [================== ] 91% (1.1s) additional asset processing
Total precache size is about 144 kB for 14 resources.
Setting up SSL certificate (may require sudo)...
INFORMATION: Es konnten keine Dateien mit dem angegebenen
Muster gefunden werden.
Attempting to spawn simplehttp2server to generate cert.
Failed to generate dev SSL certificate: Error: spawn F:\sources\Node\my-preact\node_modules\simplehttp2server\vendor\simplehttp2server_windows_amd64.exe ENOENT
Falling back to shared directory + simplehttp2server.
(dir: C:\Users\User\AppData\Roaming\preact-cli)
server error> Error: spawn F:\sources\Node\my-preact\node_modules\simplehttp2server\vendor\simplehttp2server_windows_amd64.exe ENOENT
Error: spawn F:\sources\Node\my-preact\node_modules\simplehttp2server\vendor\simplehttp2server_windows_amd64.exe ENOENT
PS F:\sources\Node\my-preact> F:\sources\Node\my-preact\node_modules\simplehttp2server\vendor\simplehttp2server_windows_amd64.exe
2017/07/27 18:51:18 Listening on https://localhost:5000...
I think it worked the first time i installed preact-cli
npm start (preact watch) works
I have also encountered this problems and looked into it:
preact serve works on bash for windows, not on powershell and cmd.
devcert-san requires openssl in Path
Since Bash for windows has openssl, everything works as expected. I get a prompt for installing the certificate, application starts serving from https://localhost:8080
when generating through simplehttp2serve
let child = execFile(simplehttp2server, ['-listen', ':40210'], {
cwd,
encoding: 'utf8'
},
shouldn't this be in the form cwd: cwd ?
I got cwd as C:\Users\usename\AppData\Roaming\preact-cli
There was no folder preact-cli inside Roaming
Creating the folder solved the ENOENT problem, but simplehttp2server shows no console output
Had to pipe to get output
2017/08/11 23:11:16 Generating certificate...
2017/08/11 23:11:17 written cert.pem
2017/08/11 23:11:17 written key.pem
2017/08/11 23:11:17 Listening on https://localhost:40210...
It stays at that and the callback isn't called.
Not sure how to proceed now, any help @thangngoc89 ?
shouldn't this be in the form cwd: cwd ?
It's ES6 short-hand syntax, same thing.
Could you try and create the cwd folder ? I don't see any obvious bug here.
btw, Windows sucks. The cwd vs Powershell alone is a huge headache. I'm using Linux Subsystem for development and never comeback
@thangngoc89 I did that already. It did start simplehttp2server, but it is stuck at Listening on https://localhost:40210...
@ethanroday the issue is when you bootstrap a project using preact-cli, it doesn't run yarn build command.
Can you please run the build and try to run yarn serve?
I got bit by this a couple of times. probably I'll add the npm run -s build to the postinstall script, that should do the work.
I thought yarn build ran preact build && preact serve anyway?
Regardless, I seem to have found a way around the problem. If I just do the setup in Git Bash rather than in Powershell everything works just fine.
Not sure whether you want to still consider this an issue - since this means it still doesn't work out of the box on Windows - so I will leave it open.
Had this same problem today. I did the setup in Git Bash and it isn't working. Still haven't found a solution.
Encountered this today. Only solution I could find was to use Git's bash. Bash for the win!
Disclaimer: I'm using npm, not yarn.
Still encountered this issue today. Preact-CLI v2.1.0

Steps to produce the error:
yarn start & yarn build work normally.
It seems a problem with yarn serve only.
I wonder why my getting started UX in any dev project is always awful 馃槀 Anyway, I'm so glad to know that a lot of awesome works has been done since v1.1.2 馃槏
Does this work if you install git within WSL?
For the record, I had a similar issue but it wouldn't even work within WSL or Git Bash.
Turned out npm install didn't run simplehttp2server's install script so the node_modules/simplehttp2server/vendor/simplehttp2server_windows_amd64.exe file really didn't exist. A simple npm install --no-save simplehttp2server fixed it for me.
I got the same issue and i tried the npm install --nosave.. but it did not do the trick.
preact serve
Setting up SSL certificate (may require sudo)...
INFO: Could not find files for the given pattern(s).
Attempting to spawn simplehttp2server to generate cert.
Failed to generate dev SSL certificate: Error: spawn C:\Users\joagun\AppData\Roaming\npm\node_modules\preact-cli\node_modules\simplehttp2server\vendor\simplehttp2server_windows_amd64.exe ENOENT
Falling back to shared directory + simplehttp2server.
I know this has worked before and the funny thing is that the .exe does exist.
Alright, I solved it.
So I'm typing my commands in the VS Code prompt. Try changing it to cmder with admin rights. Worked for me.
Hey guys, I've also stumbled upon this error on Linux (Fedora).
My error output gave me a better hint of what is happening (2nd line):
Setting up SSL certificate (may require sudo)...
cp: cannot create regular file '/usr/local/share/ca-certificates/devcert.cer': No such file or directory
Attempting to spawn simplehttp2server to generate cert.
Failed to generate dev SSL certificate: Error: spawn /home/felipewer/projects/startup_buzzer/frontend/node_modules/simplehttp2server/vendor/simplehttp2server_linux_amd64 ENOENT
Falling back to shared directory + simplehttp2server.
(dir: /home/felipewer/.preact-cli)
server error> Error: spawn /home/felipewer/projects/startup_buzzer/frontend/node_modules/simplehttp2server/vendor/simplehttp2server_linux_amd64 ENOENT
Error: spawn /home/felipewer/projects/startup_buzzer/frontend/node_modules/simplehttp2server/vendor/simplehttp2server_linux_amd64 ENOENT
Looks like an ENOENT error happens when trying to copy the devcert.cer file to /usr/local/share/ca-certificates/. This error is probably not properly handled, so it bubbles up the stack.
Creating the /usr/local/share/ca-certificates/ folder manually solved the problem and now npm run serve works. But this is only a workaround. I'll take a look at the code next, hopefully soon!
Same issue here :(
I cannot use preact serve.
I am running on windows 7, same errors as above, workarounds didn't work.
I am running into this issue currently, nightmare, tried everything it seems with no luck.
My system:
Windows 10 64bit
NVM with Node stable and 11x (on linux subsystem)
Node 11x on Windows 10
Latest Preact CLI
I tried:
Steps to reproduce:
Result:
yarn run v1.12.3
$ preact build --no-service-worker --template src/template.html && preact serve
Setting up SSL certificate (may require sudo)...
Attempting to spawn simplehttp2server to generate cert.
Failed to generate dev SSL certificate: Error: spawn C:\Users\Sean Knowles\Desktop\Dev\preact\opsap-webnode_modulessimplehttp2server\vendorsimplehttp2server_windows_amd64.exe ENOENT
Falling back to shared directory + simplehttp2server.
(dir: C:\Users\Sean Knowles\AppData\Roamingpreact-cli)
server error> Error: spawn C:\Users\Sean Knowles\Desktop\Dev\preact\opsap-webnode_modulessimplehttp2server\vendorsimplehttp2server_windows_amd64.exe ENOENT
Error: spawn C:\Users\Sean Knowles\Desktop\Dev\preact\opsap-webnode_modulessimplehttp2server\vendorsimplehttp2server_windows_amd64.exe ENOENT
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Lol just noticed these issues have been going on for over a year, whats the problem, seems that this devCert thing is causing big issues for windows users. I dont have any of these issues with Nextjs or Reactjs, its just with Preact, I cant build and serve the production version.
It has been a year since my last post 馃槀.
I'm not using preact-cli as my main dev tool due to this problem.
Had better improving our webpack-fu instead of relying on the cli.
Yea same, was literally testing Preact CLI for an mvp then came across this issue and am moving away, it might be trivial but the issue hasn't been resolved for quite some time.
Not sure why I'm assigned. This wasn't a smooth process for me either. Part of the reason why I've advocated to get rid of serve entirely for next release.
This is a permissions thing, and we're totally at the mercy of what simplehttp2server is permitted to do.
My guess is that it has to do with how users' machines have installed node and npm. Specifically, if sudo is granted to the installation or not. Since 99% of the reports here are Windows, I'm betting that's the case.
What's wrong with just using webpack-dev-server? Then users can have hot reloading, but I'm not sure if that will conflict with the pre-rendering step.
The serve command was added for testing within a http2, production-like setting. WDS does not offer that feature
Is there a solution, because currently windows users are having trouble/impossible to test production build locally... surely there is a better solution? Basics issues like these just turns me away from using a technology if you catch my drift. This issue has been here for over a year, and just hasn't really been addressed. Admittedly I am junior dev and have no idea how big a fix this is. Is there another way I can test the local build?
@skdigital Sure, understood. As mentioned it's not something we actually have control over. The best solution was to just get rid of it going forward. In the interim, you can just use any http server on the production directory. For example, I use sirv-cli for testing. There's no HTTP/2 (yet) but the important part (imo) is to just get it up & running as a sanity check.
$ npm install -g sirv-cli
$ npm run build
$ sirv build --single
Cheers boss, working nice!
Is there a discord or slack channel for Preact?
Great! Yup we're over in https://preact.slack.com
Thought you might be the most appropriate person talk about this, that's why I assigned you
I had the same issues running serve. Another alternative on Windows with VS Code is to use the IIS Express extension (in VS Code).
npm run build anytime after that and refresh your browser to check the production build.Not sure why I'm assigned. This wasn't a smooth process for me either. Part of the reason why I've advocated to get rid of
serveentirely fornextrelease.This is a permissions thing, and we're totally at the mercy of what
simplehttp2serveris permitted to do.My guess is that it has to do with how users' machines have installed
nodeandnpm. Specifically, ifsudois granted to the installation or not. Since 99% of the reports here are Windows, I'm betting that's the case.
Install Git on your Windows, run it as administrator, create a sample preact project, then it will be no issue when you run yarn serve or npm run serve
...or maybe we can just use a server that actually works? HTTP/2 is an unnecessary feature. If they really want it that badly, they can use their own solution.
For me right now, all the serve command does is frustrate Windows users and confuse developers trying to run their app the first time.
Have same problem on Ubuntu 18.04.
I just a little bit looking around and I discovered that simplehttp2server folder not included vendor folder with binary file. I simply navigated into /node_modules/simplehttp2server/ and install the binnary:
$ cd /node_modules/simplehttp2server/
$ npm install
$ cd <back to project root>
$ preact serve
The vendor directory has created include missed binary file and preact serve start working.
I don't know the reason why they all needed dependencies has not successfully installed by "npm install" inside the project, but only want to help to solve this issue without waste time to find the main reason.
@rrsoftcz simplehttp2server was removed in Preact CLI version 3 (currently in preview) since the preact serve command was removed (for now).
Most helpful comment
@skdigital Sure, understood. As mentioned it's not something we actually have control over. The best solution was to just get rid of it going forward. In the interim, you can just use any http server on the production directory. For example, I use
sirv-clifor testing. There's no HTTP/2 (yet) but the important part (imo) is to just get it up & running as a sanity check.