I want to write out a log line that reads “started version 0.4.0” when I start up the server, where the version is taken from the package.json
file.
I defined a module and I’m passing it the version from the nuxt.config.ts
file like so:
import pkg from './package.json'
export default defineNuxtConfig({
//...
modules: [
//...
['~/modules/server-startup-log', { version: pkg.version }]
]
})
The module’s code is:
import { defineNuxtModule } from '@nuxt/kit'
export default defineNuxtModule({
setup(options) {
console.log(`Started version ${options.version}`);
}
})
This only works if I run the server in dev mode, but after I build the
app it no longer prints the line on start up? Why is that? How can I get
this line to print after building as well?