In Firefly example project in package.json
there is
"start": "sh -ac '. ./.env.dev; firebase use dev && react-scripts start'",
On my Windows 10 its not working with &&
:
Now using alias dev (firefly-boilerplate) Unknown script "start'". react-scripts start'
This script works with ;
instead of &&
, App starts, but it doesn't connect fo database:
@firebase/firestore: Firestore (5.0.4): Could not reach Cloud Firestore backend. Connection failed 2 times. Most recent error: FirebaseError: [code=not-found]: The project firefly-boilerplate
does not exist or it does not contain an active Cloud Datastore database.
So I must put Api key, domain, and project name from .env.dev
into index.js
to work. Why this script doesn't work with &&
?
What sh -ac
command exacly do?
sh
is the POSIX command for running a shell (a shell is the program that powers the command-line terminal). Running sh -ac
is saying "run the shell command and automatically export all variables assigned during its run" effectively.
A .env
file is often used to describe local environment variables needed for scripts to run, so sh -ac ./.env.dev
is basically saying load all the environment variables from .env.dev
.
Those environment variables are then made available in the subsequent commands via &&
which executes multiple commands in a single context.
This script is, simply speaking, not very Windows-friendly. What you would want to do is take a look inside .env.dev
at the environment variables it's setting and then set those in your local terminal before running the firebase
and react-scripts
commands.
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