nuxt/cli

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

Opened this issue · 0 comments

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?