Skip to content
Jonathan Sharpe edited this page May 12, 2021 · 43 revisions

Welcome to the starter-kit wiki! If you're new to this kit, you might find the following pages useful to get a high-level idea of how it fits together:

or if you just want to get going:

If you're a Code Your Future trainee or instructor, there's a channel on the CYF Slack for discussion, feedback or questions: #cyf-full-stack-starter-kit (but please do read the material here first!)

Common errors

If you're here because you've got an error, maybe it's one of the following:

Error Reason Solution
sh: <package>: command not found or <package> is not recognized as an internal or external command, operable program or batch file (usually <package> will be concurrently or rimraf) The required dependencies are not installed. See Dev setup#Installation
EADDRINUSE You have something else listening to ports (3000, maybe also 3100) the starter kit wants to use. See Dev setup#Ports
Error: Cannot find module 'path/to/dist/server.js' You're trying to run the start script and start the production server without having built the app. Don't run npm [run] start locally, see the Scripts.
SyntaxError: Cannot use import statement outside a module You're trying to run the raw source code, rather than the transpiled output, e.g. using node server/server.js. Don't try to run the source code directly, see Scripts.
Two different lockfiles found: package-lock.json and yarn.lock You're mixing two different package managers, NPM and Yarn. See Yarn if you want to switch or make everyone stick with NPM.
No 'Access-Control-Allow-Origin' header is present on the requested resource. You're making absolute requests (e.g. "http://localhost:3100/api/something") to the server, which don't go via the dev server's proxy (see Architecture). This starter kit is set up to use relative routes between the frontend and the backend (this avoids CORS and configuration issues in production), access e.g. "/api/something" instead.
Refused to load something because it violates the following Content Security Policy directive Helmet isn't configured correctly and is blocking some of your resources. See Content Security Policy.
Frontend is stuck on "Loading..." This happens if the request to the backend /api endpoint fails. If you're using the CYF fork, you may not have a database running. See Dev setup#Databases. If you have a database running or don't need it, check the server logs for the other common errors listed here.
I'm using dotenv but process.env.<SOMETHING> is undefined in the React app code Not all Create React App features are implemented here, including the REACT_APP_ env var autoloading. See Client environment variables.
UnhandledPromiseRejection (Node >= 15) or UnhandledPromiseRejectionWarning (Node < 15) Somewhere, most likely in one of your Express handler functions, there's a rejected promise that isn't being handled correctly. See Unhandled promise rejections.
error: database "cyf" does not exist You're using Postgres on localhost (not via DATABASE_URL) but haven't created the appropriate database. Run createdb cyf (if you're using Docker you may need to set some options, see Dev setup#Postgres).
MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017 You don't have MongoDB running. See Dev setup#MongoDB.
Error: connect ECONNREFUSED 127.0.0.1:5432 You don't have Postgres running. See Dev setup#Postgres.
error: password authentication failed for user <user> If you're using e.g. Docker to run Postgres, you may need to provide a username and password. See Dev setup#Postgres.
None of the above Open an issue.
Clone this wiki locally