{"record":{"id":"45a7e6f9b2bf3f94","repo":"quasarframework/quasar","slug":"the-prefix-env-prefix-is-invalid-in-js-allow","errorCode":null,"errorMessage":"The \"${prefix}\" env prefix is invalid in JS. Allowing all env keys that are valid in JS (without any prefix).","messagePattern":"The \"(.+?)\" env prefix is invalid in JS\\. Allowing all env keys that are valid in JS \\(without any prefix\\)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app-vite/lib/utils/env.js","lineNumber":58,"sourceCode":"  .reduce((acc, key) => {\n    acc[key] = process.env[key]\n    return acc\n  }, {})\n\nfunction getEnvFilesPrefix({ prefix, defaultPrefix, banner }) {\n  if (!prefix) {\n    if (!defaultPrefix) return ''\n    warn(\n      `No env prefix specified, using default \"${defaultPrefix}\" instead.`,\n      banner\n    )\n    return defaultPrefix\n  }\n\n  if (!Array.isArray(prefix)) {\n    if (!validEnvKeyRE.test(prefix)) {\n      if (!defaultPrefix) {\n        warn(\n          `The \"${prefix}\" env prefix is invalid in JS. Allowing all env keys that are valid in JS (without any prefix).`,\n          banner\n        )\n        return ''\n      }\n\n      warn(\n        `Invalid env prefix specified, using default \"${defaultPrefix}\" instead.`,\n        banner\n      )\n      return defaultPrefix\n    }\n\n    return prefix\n  }\n\n  const validPrefixList = []\n  for (const entry of prefix) {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/quasarframework/quasar/blob/4841521b5f635a971eb9e2710e5542efd194691b/app-vite/lib/utils/env.js#L40-L76","documentation":"When env.prefix is a single string, it must match /^[a-zA-Z_$][a-zA-Z0-9_$]*$/ because prefixed variables become import.meta.env.<PREFIX><KEY> identifiers in JS. An invalid prefix cannot produce valid JS keys, so with no defaultPrefix available the function warns and allows all JS-valid env keys without any prefix.","triggerScenarios":"quasar dev/build with quasar.config > env > prefix set to a string failing validEnvKeyRE (e.g. 'MY-APP_', '2APP_', contains spaces/hyphen/%%) and defaultPrefix being empty; called from the prefix/clientPrefix/backendPrefix getters.","commonSituations":"Using kebab-case names, copying OS env var names like 'ProgramFiles(x86)' style, or accidentally passing a number/boolean-ish value as prefix.","solutions":["Change the prefix to a valid JS identifier, e.g. 'MYAPP_' instead of 'MY-APP_'.","Rename related .env variable prefixes to match the corrected prefix.","If you truly want all valid env keys exposed, remove the prefix option instead of passing an invalid one."],"exampleFix":"// before (quasar.config)\nenv: { prefix: 'MY-APP_' }\n// after\nenv: { prefix: 'MYAPP_' }","handlingStrategy":"validation","validationCode":"const validEnvKeyRE = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/\nconst p = conf.env?.prefix\nif (typeof p === 'string' && p && !validEnvKeyRE.test(p)) {\n  throw new Error(`env.prefix \"${p}\" is not a valid JS identifier`)\n}","typeGuard":"function isValidEnvPrefix(v) {\n  return typeof v === 'string' && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(v)\n}","tryCatchPattern":null,"preventionTips":["Use only [A-Za-z0-9_$] with a non-digit first character; prefer uppercase with trailing underscore.","Avoid hyphens/spaces in prefixes even if your .env keys use them.","Lint quasar.config with a quick regex check in CI."],"tags":["env","config","naming"],"backgroundTag":"invalid-env-prefix","analyzedSha":"4841521b5f635a971eb9e2710e5542efd194691b","analyzedAt":"2026-08-30T01:13:14.944Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}