admin管理员组

文章数量:1323176

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 mand exacly do?

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 mand exacly do?

Share Improve this question asked Jul 1, 2018 at 12:58 kondziorfkondziorf 1371 silver badge8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

sh is the POSIX mand for running a shell (a shell is the program that powers the mand-line terminal). Running sh -ac is saying "run the shell mand 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 mands via && which executes multiple mands 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 mands.

本文标签: javascriptPackagejson complicated start script with quotsh acquot and env file for FirebaseStack Overflow