I want to run a React project in my Windows (as a virtual machine of my Mac).
In a Command Prompt, after running yarn
to install dependencies. I did yarn start
. And it gave me 'HTTPS' is not recognized as an internal or external command
error.
> yarn start
yarn run v1.13.0
$ HTTPS=true CERT=cert/localhost.crt KEY=cert/localhost.key umi dev
'HTTPS' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Does anyone know how to fix this?
Edit 1:
I upgraded node to v12.16.1
(yarn
to 1.13.0
, npm to 6.13.4
), and did yarn add https
and yarn add https-localhost
. However, yarn start
still returned 'HTTPS' is not recognized as an internal or external command
.
umi dev
returned 'umi' is not recognized as an internal or external command, operable program or batch file.
:
>umi dev
'umi' is not recognized as an internal or external command,
operable program or batch file.
Just add the following lines to .env
:
HTTPS=true
PORT=8080
HOST=localhost
If you want to use another host or port, feel free to replace localhost by the IP address you want and the port with any available port number. If you don't have .env
file, just create it in your react root folder.
After this you can run yarn start
or npm start
and your project will use https instead of http
.
If you need to use a real certificate inatead of a self-signed, the you can take a look at may answer here: How can I provide a SSL certificate with create-react-app?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With