Skip to content

Make nuxi prepare run with NODE_ENV set to "development" by default #460

Open
@wokalek

Description

@wokalek

Why was the default mode set to production when running from the command line without setting the NODE_ENV env variable?

I'm talking about this line in the command:

process.env.NODE_ENV = process.env.NODE_ENV || 'production'

Typically, in nuxt.config.ts you might have logic like this:

if (process.env.NODE_ENV === 'development') {
    config.modules?.push('@nuxt/eslint')
}

I need this to avoid installing the @nuxt/eslint module when installing dependencies without development dependencies with pnpm install --prod on the production server, because otherwise I get an error if I just specify the @nuxt/eslint module in the modules section. I need this condition for that.

However, this condition does not work because I simply run pnpm postinstall, process.env.NODE_ENV is set to production and as a result the ./.nuxt/eslint.config.mjs file is not created for the module @nuxt/eslint to work. There may be other things for development that don't work with other modules or don't generate types.

Besides, the .nuxt folder is needed exclusively for development, not for the production build. So why is it set to production by default, and not development?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions