Static GitHub Issues

[2816] Error when restarting nuxt server

prev: How does the Static directory work with CDN?
next: How to include .sss files? (sugarss)

Hello,

Whenever I rebuild and then restart the server.js script, I receive the following error on tabs that have this site open:

ERROR in ./.nuxt/index.js
Module not found: Error: Can't resolve 'plugin12' in '/home/test/.nuxt'
 @ ./.nuxt/index.js 296:0-32
 @ ./.nuxt/client.js
 @ multi webpack-hot-middleware/client?name=client&reload=true&timeout=3000&path=/__webpack_hmr ./.nuxt/client.js

Is it possible to rebuild & restart the server without having this error for people that are browsing the site? They have to refresh the page now before they can continue on the site.

I don't really understand why this happens. There is no hot reloading on a live production server.

Below is the server.js script

const { Nuxt, Builder } = require('nuxt')

const https = require('https')
const fs = require('fs')
const isProd = (process.env.NODE_ENV === 'production')
const port = process.env.PORT || 3000

// We instantiate nuxt.js with the options
const config = require('./nuxt.config.js')
config.dev = !isProd
const nuxt = new Nuxt(config)

// Render every route with Nuxt.js

// Build only in dev mode with hot-reloading
if (config.dev) {
  new Builder(nuxt).build()
  .then(listen)
  .catch((error) => {
    console.error(error)
    process.exit(1)
  })
}
else {
  listen()
}

function listen() {
	const options = {
key: fs.readFileSync('/home/test/certs/test.key'),
cert: fs.readFileSync('/home/test/certs/test.crt')
};
  // Listen the server
// Create the server
https
.createServer(options, nuxt.render)
.listen(port)
  console.log('Server listening on `localhost:' + port + '`.')
}
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2445">#c2445</a>)</em></sub></div>