kriasoft / react-firebase-starter

Boilerplate (seed) project for creating web apps with React.js, GraphQL.js and Relay
https://firebase.reactstarter.com
MIT License
4.51k stars 755 forks source link

Error while running boilerplated code #287

Open alpeshrpatel opened 6 years ago

alpeshrpatel commented 6 years ago

I m facing with this. Can someone please suggest something ?

(undefined) ./src/account/Account.js Module not found: Can't resolve './generated/AccountFragment.graphql' in '/Users/alpeshpatel/workspace/javascript/react/react-firebase-starter/src/account'

koistya commented 6 years ago

You need to pre-compile GraphQL queries used in code before launching the app either by running yarn relay or yarn relay --watch (in "watch" mode).

alpeshrpatel commented 6 years ago

Still facing on this issue.

alpeshpatel@XXXXXXXX:~/workspace/javascript/react/react-firebase-starter$yarn relay yarn run v1.5.1 $ relay-compiler --src ./src --schema ./src/schema.graphql --include "*/.js" 2018-03-14T11:55:15,351: [cli] unable to talk to your watchman on /usr/local/var/run/watchman/alpeshpatel-state/sock! (No such file or directory)

Watchman: watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= 2018-03-14T11:55:15,351: [cli] unable to talk to your watchman on /usr/local/var/run/watchman/alpeshpatel-state/sock! (No such file or directory)

HINT: pass --watch to keep watching for changes.

Writing js Unchanged: 0 files ✨ Done in 143.70s.

koistya commented 6 years ago

@alpeshrpatel do you have Facebook's Watchman installed? What version? watchman --version

alpeshrpatel commented 6 years ago

alpeshpatel@ALPESHs-MacBook-Pro.local:~/workspace/javascript/react/react-firebase-starter$watchman --version 4.9.0

koistya commented 6 years ago

Try get get logs from watchman, here is a related issue https://github.com/facebook/watchman/issues/143

nnmrts commented 6 years ago

~Some change in the last few days broke this starter repo.~ I used it successfully a week ago, now when I run yarn setup it exits with this after installing the dependencies:

[4/4] Building fresh packages...
success Saved lockfile.
{ Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object._errnoException (util.js:1024:11)
    at _exceptionWithHostPort (util.js:1046:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 5432 }
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c node ./scripts/setup
Directory: /home/nnmrts/projects/bibliopol3
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/home/nnmrts/projects/bibliopol3/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

EDIT: This issue and the issue described in the first post comes from not editing the .env file.


However, how do I correctly edit this file? Firebase config is obvious, but how do I have to set the postgresql vars? What should PGPASSWORD be? What is this thing even and why do I need it? I thought this starter uses graphql?

nnmrts commented 6 years ago

Don't know if this is useful, but I got it working now: The readme.md "getting started" section should be rewritten to this:

First clone the repository in a directory and cd into it:

git clone https://github.com/kriasoft/react-firebase-starter.git MyApp
cd MyApp

Then install PostgreSQL if it isn't already installed and give the default user a password:

sudo -u postgres psql // login to postgresql shell
ALTER USER postgres PASSWORD 'your_password'; // add a password

Then edit the firebase config in the .env file and add that password above to the postgres config:

PGHOST=localhost
PGUSER=postgres
PGDATABASE=app
PGPASSWORD=your_password
PGPORT=5432
# PGSSLMODE=require
PGSSLMODE=disable

Now setup and start your app: yarn setup && yarn start

PS: Be sure to either add your .env file to your .gitignore file or rename it to .env.local, otherwise other people can see your postgres password and firebase keys when you git push your source code somewhere.

alpeshrpatel commented 6 years ago

Does that mean i need postgres locally install ? i dont want it then what would be steps to follow ?

koistya commented 6 years ago

@alpeshrpatel you would just need to modify src/graphql/user/mutations.js => signIn() mutation and src/graphql/user/UserType.js to use some other storage, e.g. in Firestore. After that, you will be able to sign in. And remove stories/comments from the project, as they are just examples.

koistya commented 6 years ago

@nnmrts you can use "postgres" account without a password (a password being an empty string), in that case, the yarn setup script with default settings should bootstrap a new database without any issues. Yeah, it would be nice to add a comment to .env file that it should not contain any real secrets/passwords if the project is being pushed to a public repo. A pull request is more than welcome!

nnmrts commented 6 years ago

@koistya I also read that "without a password"-thing somewhere else, but for my machine (linux debian 32 bit) this didn't work. Maybe that was just because I manually installed the desktop environment. :/

Nevertheless, I still can't deploy my project because of this:

Error: Error parsing triggers: The gRPC binary module was not installed. This may be fixed by running "npm rebuild"
Original error: Cannot find module '/home/nnmrts/projects/bibliopol3/node_modules/@google-cloud/common-grpc/node_modules/grpc/src/node/extension_binary/node-v59-linux-ia32-glibc/grpc_node.node'

Try running "npm install" in your functions directory before deploying.

Weird enough, because there is no functions directory. Still don't know if this is related, but it's definitely an edge case...should I open a new issue for this?

(also, I'm afraid to run npm rebuild now, because I use yarn and npm would screw everything up :D (I will still try it though))

Anyway, how do I solve this?


EDIT: I should also point out that deploying went fine until I installed a dependency with yarn and required it in server.js.

nnmrts commented 6 years ago

My suggestion is to fully remove PostgreSQL from this starter. It's just an overload. This starter really worked great a week ago and now it just feels painful to work with.


EDIT: npm rebuild fixed it for me, but still, I don't see why this starter needs PostgreSQL...

alpeshrpatel commented 6 years ago

Please keep me posted once you remove postgreSQL from start kit. I would say RDBMS should be user preference instead of PostgreSQL. If use want then they can involve them self

koistya commented 6 years ago

@alpeshrpatel you still need a database for data, right? Can I ask, what kind of data you need to store and what db are you going to use instead of Postgres?

alpeshrpatel commented 6 years ago

I am planning to use mongo and firebase. Starter kit should not depend on any DB. Its should generic. Let me know if you need more info on this.

nnmrts commented 6 years ago

@alpeshrpatel cosign

alpeshrpatel commented 6 years ago

Any luck on this ?

nnmrts commented 6 years ago

@alpeshrpatel I'm planning to release an easier starter, based on an earlier version of this starter. I used it myself for the last two months. It's not dependent on any database framework and just works fine.

nnmrts commented 6 years ago

@alpeshrpatel But protip: You just can clone any version before this commit: https://github.com/kriasoft/react-firebase-starter/commit/e255dfca3298f78ed730560b395bf51edc3e36b7

and then remove the graphql dependencies and the components that use it. Removing PostgreSQL in the current version is way harder. Also, in this earlier version you just need to enter yarn to start your project.

nnmrts commented 6 years ago

Unfortunately this repo doesn't use git tags and releases the way they should be used. The one and only release is this, but it's almost two years old and I never tried it out. It probably works too, but much luck with updating the dependencies.

Any thoughts on this, @koistya?

nnmrts commented 6 years ago

And sorry for quadruple post, but I find it kinda sad that there is not a single usable and generic simple boilerplate for React. create-react-app works fine as a "tutorial" like project, but for simple and small real projects, there is no such thing as a boilerplate. Everything above create-react-app needs either an uneccessary complicated setup of requirements and prerequisites or is built way too opinionated to work with for most of the people. :frowning_woman:

EDIT: Classic case of featuritis.