quasarframework/quasar · warning
The "${prefix}" env prefix is invalid in JS. Allowing all en
Error message
The "${prefix}" env prefix is invalid in JS. Allowing all env keys that are valid in JS (without any prefix). What it means
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.
Source
Thrown at app-vite/lib/utils/env.js:58
.reduce((acc, key) => {
acc[key] = process.env[key]
return acc
}, {})
function getEnvFilesPrefix({ prefix, defaultPrefix, banner }) {
if (!prefix) {
if (!defaultPrefix) return ''
warn(
`No env prefix specified, using default "${defaultPrefix}" instead.`,
banner
)
return defaultPrefix
}
if (!Array.isArray(prefix)) {
if (!validEnvKeyRE.test(prefix)) {
if (!defaultPrefix) {
warn(
`The "${prefix}" env prefix is invalid in JS. Allowing all env keys that are valid in JS (without any prefix).`,
banner
)
return ''
}
warn(
`Invalid env prefix specified, using default "${defaultPrefix}" instead.`,
banner
)
return defaultPrefix
}
return prefix
}
const validPrefixList = []
for (const entry of prefix) {View on GitHub (pinned to 4841521b5f)
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.
Example fix
// before (quasar.config)
env: { prefix: 'MY-APP_' }
// after
env: { prefix: 'MYAPP_' } Defensive patterns
Strategy: validation
Validate before calling
const validEnvKeyRE = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/
const p = conf.env?.prefix
if (typeof p === 'string' && p && !validEnvKeyRE.test(p)) {
throw new Error(`env.prefix "${p}" is not a valid JS identifier`)
} Type guard
function isValidEnvPrefix(v) {
return typeof v === 'string' && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(v)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Using kebab-case names, copying OS env var names like 'ProgramFiles(x86)' style, or accidentally passing a number/boolean-ish value as prefix.
Related errors
- Invalid env prefix specified, using default "${defaultPrefix
- No env prefix specified, using default "${defaultPrefix}" in
- Invalid env prefix "${entry}" specified in the array. Skippi
- No valid env prefix specified in the array. Allowing all env
- Build output directory must be a non-empty path
AI-assisted analysis of quasarframework/quasar@4841521b5f (2026-08-30).
Data as JSON: /api/errors/45a7e6f9b2bf3f94.
Report an issue: GitHub.