{"record":{"id":"5abc5cf41214b9ab","repo":"react/create-react-app","slug":"you-specified-type-in-your-env-but-the-file","errorCode":null,"errorMessage":"You specified ${type} in your env, but the file \"${file}\" can't be found.","messagePattern":"You specified (.+?) in your env, but the file \"(.+?)\" can't be found\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-scripts/config/getHttpsConfig.js","lineNumber":45,"sourceCode":"    );\n  }\n\n  try {\n    // privateDecrypt will throw an error with an invalid key\n    crypto.privateDecrypt(key, encrypted);\n  } catch (err) {\n    throw new Error(\n      `The certificate key \"${chalk.yellow(keyFile)}\" is invalid.\\n${\n        err.message\n      }`\n    );\n  }\n}\n\n// Read file and throw an error if it doesn't exist\nfunction readEnvFile(file, type) {\n  if (!fs.existsSync(file)) {\n    throw new Error(\n      `You specified ${chalk.cyan(\n        type\n      )} in your env, but the file \"${chalk.yellow(file)}\" can't be found.`\n    );\n  }\n  return fs.readFileSync(file);\n}\n\n// Get the https config\n// Return cert files if provided in env, otherwise just true or false\nfunction getHttpsConfig() {\n  const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;\n  const isHttps = HTTPS === 'true';\n\n  if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {\n    const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);\n    const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);\n    const config = {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/react/create-react-app/blob/6254386531d263688ccfa542d0e628fbc0de0b28/packages/react-scripts/config/getHttpsConfig.js#L27-L63","documentation":"getHttpsConfig.readEnvFile is called with the value of an HTTPS-related env var (SSL_CRT_FILE or SSL_KEY_FILE) and a human label. If the path does not exist on disk (fs.existsSync returns false), it throws, telling the user which variable type they set and which file path could not be found.","triggerScenarios":"Setting SSL_CRT_FILE or SSL_KEY_FILE (and HTTPS=true) in .env to a path that does not resolve from the project root. readEnvFile runs, fs.existsSync returns false, and the error is thrown.","commonSituations":"Typo in the path. Using a relative path that doesn't resolve from CWD. Moving the project without moving the cert files. Forgetting to commit/copy cert files in a fresh checkout. Absolute paths from another machine.","solutions":["Confirm the file exists at the exact path: `ls -la $SSL_CRT_FILE $SSL_KEY_FILE`.","Use paths relative to the project root (where react-scripts runs) or absolute paths that exist on this machine.","Place cert/key in the project folder and reference them as `./cert.pem` / `./key.pem`.","If you no longer need custom certs, unset SSL_CRT_FILE/SSL_KEY_FILE (and HTTPS) to let CRA generate one with selfsigned certs."],"exampleFix":"# before\nSSL_CRT_FILE=/home/olduser/certs/localhost.crt   # missing\nSSL_KEY_FILE=/home/olduser/certs/localhost.key\n# after\nSSL_CRT_FILE=./localhost.crt   # exists in project root\nSSL_KEY_FILE=./localhost.key","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst path = require('path');\nfunction ensureSslFiles() {\n  for (const [type, file] of [\n    ['SSL_CRT_FILE', process.env.SSL_CRT_FILE],\n    ['SSL_KEY_FILE', process.env.SSL_KEY_FILE],\n  ]) {\n    if (file && !fs.existsSync(path.resolve(process.cwd(), file))) {\n      throw new Error(`${type} '${file}' does not exist`);\n    }\n  }\n}\nensureSslFiles();","typeGuard":"const sslFileExists = (file) =>\n  !file || fs.existsSync(path.resolve(process.cwd(), file));","tryCatchPattern":"try {\n  require('react-scripts/config/getHttpsConfig');\n} catch (e) {\n  if (new RegExp(\"can't be found\").test(e.message)) {\n    console.error('SSL_CRT_FILE/SSL_KEY_FILE path missing. Check .env paths.');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Store cert/key inside the project and reference them by relative path.","Add a preflight check that the files exist before starting the dev server.","Commit cert paths to .env but keep the files out of git (use a setup script).","After cloning/moving a project, re-verify SSL_*_FILE paths."],"tags":["https","ssl","file-not-found","config","filesystem"],"backgroundTag":null,"analyzedSha":"6254386531d263688ccfa542d0e628fbc0de0b28","analyzedAt":"2026-08-12T22:55:01.751Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}