Skip to content
Jonathan Sharpe edited this page Aug 24, 2024 · 43 revisions

Note if you're using v1 of the starter kit (i.e. you have client/ and server/ directories rather than api/ and web/, see v1 Home.

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
<number> <level> severity vulnerabilities To address issues that do not require attention... Some security vulnerabilities have been reported within your dependencies You may be able to install fixed versions, see Dependencies#audit
npm ERR! code EBADENGINE, npm ERR! engine Unsupported engine This starter kit is tested and supported on the current LTS versions of Node: 18 (NPM 8/9) and 20 (NPM 9) See Dev setup#Requirements
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it! You're using a v2 package-lock.json with NPM 6 Use consistent versions of NPM, see Dev setup#Lockfile versions
npm ERR! Cannot read property '@babel/runtime' of undefined You're using a v3 package-lock.json with NPM 6 Use consistent versions of NPM, see Dev setup#Lockfile versions
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). Do not install the Express cors middleware! 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 Dotenv#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).
Error: connect ECONNREFUSED 127.0.0.1:5432 You don't have Postgres running. See Dev setup#postgres.
TypeError: Invalid URL If it's coming from node_modules/pg-connection-string/ via server/db.js, your dbUrl is incorrect. See Dev setup#postgres.
error: password authentication failed for user <user> or error: Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string If you're using e.g. Docker to run Postgres, you may need to provide a username and password. See Dev setup#Postgres.
Module not found: Error: Can't resolve './path/to/File' in 'path/to/starter-kit/client/src' You're trying to import a non-.js file without an explicit extension. See JSX file extension
Module parse failed: Unexpected token You're trying to import a file containing unsupported syntax. See JSX file extension
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it. You're trying to import a library designed to run in the Node environment in the React app (client/), which runs in the browser environment. Don't! The Express app (server/) is what runs in the Node environment, any imports of e.g. database tools should happen there.
None of the above Open an issue.
Clone this wiki locally