'Nuxt application local development server constantly reloading
I have a Nuxt ^2.15.8 application which is constantly reloading after I run yarn dev.
The console will show a message like ↻ Updated 1647868577626, and then the application is rebuilt, as if I just run yarn dev. This happens constantly over and over, without me doing any changes in the code.
I googled a bit, and found applications like gitkraken might be modifying the content of the .git folder and that could trigger a reload.
So I keep gitkraken closed.
I also added these lines to my nuxt.config.js file:
watchers: {
webpack: {
ignored: [
'**/*.{md,log,prettierignore,prettierrc,stylelintignore,npmrc,gitignore}',
'**/.git/**',
],
},
},
That doesn't fix the issue though
My main question is: what would the line ↻ Updated 1647868577626 mean, and what could be causing it? I get the feeling that if I want to solve my problem, I need to answer that question.
Edit: this is my full nuxt.config.js file
import fs from 'fs'
import path from 'path'
// TODO Migrate from dotenv to runtime config https://nuxtjs.org/tutorials/moving-from-nuxtjs-dotenv-to-runtime-config/
import { config } from 'dotenv'
config()
// eslint-disable-next-line import/first
import { exportSitePayload, getSitePayload } from './scripts/prepare-for-build'
// eslint-disable-next-line import/first
process.env.NUXT_TARGET_MODE
= process.env.NUXT_TARGET_MODE || (process.env.NETLIFY ? 'static' : 'server')
const isProd
= /prod/i.test(process.env.NODE_ENV)
|| process.env.NETLIFY
|| (process.env.HEROKU && process.env.PP_ENV === 'production')
const isStaging
= !isProd
&& (/stag/i.test(process.env.NODE_ENV) || (process.env.HEROKU && process.env.PP_ENV === 'staging'))
const isDev = !(isProd || isStaging)
export default async function() {
await exportSitePayload({
...(process.env.STATIC_HOST ? { staticHost: process.env.STATIC_HOST } : {}),
...(process.env.HEROKU ? { all: true } : {}),
})
return {
ssr: process.env.SSR !== 'false',
target: process.env.NUXT_TARGET_MODE,
components: [
{ path: '~/components/', pathPrefix: false },
{ path: '~/components', pathPrefix: true, level: 1 },
],
env: {
SANITY_PROJECT_ID: process.env.SANITY_PROJECT_ID,
SANITY_PROJECT_DATASET: process.env.SANITY_PROJECT_DATASET,
},
publicRuntimeConfig: {
apiBaseURL: process.env.API_BASE_URL,
forceAPIBaseURL: process.env.FORCE_API_BASE_URL,
ppEnv: process.env.PP_ENV,
archivedMode: process.env.ARCHIVED_MODE,
archivedModeLiveLink: process.env.ARCHIVED_MODE_LIVE_LINK,
attendeeAPILinkedInCallback: process.env.ACCOUNT_ENDPOINT_LINKEDIN_CALLBACK,
attendeeAPILogout: process.env.ACCOUNT_ENDPOINT_LOGOUT,
attendeeAPIVerifyLogincode: process.env.ACCOUNT_ENDPOINT_VERIFY_LOGINCODE,
attendeeAPIMagicLinkRequest: process.env.ACCOUNT_ENDPOINT_MAGIC_LINK_REQUEST,
attendeeAPIRegister: process.env.ACCOUNT_ENDPOINT_REGISTER,
attendeeAPIUserInfo: process.env.ACCOUNT_ENDPOINT_USER_INFO,
devDisableCache: process.env.DEV_DISABLE_CACHE,
eventAPIDetails: process.env.EVENT_ENDPOINT_DETAILS,
eventAPIBadge: process.env.EVENT_ENDPOINT_BADGE,
liveEventAPIStage: process.env.LIVE_EVENT_ENDPOINT_STAGE,
liveEventAPIChat: process.env.LIVE_EVENT_ENDPOINT_CHAT,
orderAPICustomer: process.env.ORDER_ENDPOINT_CUSTOMER,
orderAPICart: process.env.ORDER_ENDPOINT_CART,
orderAPIInfo: process.env.ORDER_ENDPOINT_INFO,
orderAPIInvoice: process.env.ORDER_ENDPOINT_INVOICE,
paymentAPIMethods: process.env.PAYMENT_API_METHODS,
productAPIInfo: process.env.PRODUCT_ENDPOINT_INFO,
staticHost: process.env.STATIC_HOST,
streamChatAPIKey: process.env.STREAM_CHAT_API_KEY,
streamChatAPPId: process.env.STREAM_CHAT_APP_ID,
ticketAPIDetails: process.env.TICKET_ENDPOINT_DETAILS,
ticketAPIList: process.env.TICKET_ENDPOINT_LIST,
userAPIOrders: process.env.USER_ENDPOINT_ORDERS,
videoAPIDetails: process.env.VIDEO_API_ENDPOINT_DETAILS,
videoAPILists: process.env.VIDEO_API_ENDPOINT_LISTS,
videoAPIUploadInfo: process.env.VIDEO_API_ENDPOINT_UPLOAD_INFO,
isProd,
isStaging,
isDev,
},
/*
** Headers of the page
*/
head: {
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'viewport',
name: 'viewport',
content: 'width=device-width, initial-scale=1',
},
],
link: [
{ rel: 'stylesheet', href: 'https://use.typekit.net/fag0imi.css' },
{ rel: 'stylesheet', href: '/theme.css' },
{ rel: 'stylesheet', href: '/static_theme.css' },
],
},
/*
** Customize the progress-bar color
*/
loading: { color: 'var(--color-primary-500)' },
/*
** Global CSS
*/
css: [],
/*
** Plugins to load before mounting the App
*/
plugins: [
'~/plugins/vuelidate.js',
'~/plugins/filters.js',
'~/plugins/lazyload.js',
'~/plugins/reactive-provide.js',
'~/plugins/vue-form-wizard',
'~/plugins/vue-phone-number-input',
'~/plugins/vue-selectize',
'~/plugins/sanity-block-vue-component.js',
'~/plugins/youtube.client.js',
'~/plugins/v-tooltip.js',
'~/plugins/axios.js',
{ src: 'plugins/vue-typer.client.js', ssr: false },
],
/*
** Nuxt.js dev-modules
*/
buildModules: [
'@nuxt/postcss8',
// https://typescript.nuxtjs.org/
'@nuxt/typescript-build',
// https://composition-api.nuxtjs.org/getting-started/setup
'@nuxtjs/composition-api/module',
// Doc: https://github.com/nuxt-community/eslint-module
'@nuxtjs/eslint-module',
// Doc: https://github.com/nuxt-community/nuxt-tailwindcss
'@nuxtjs/tailwindcss',
'@nuxtjs/dotenv',
],
/*
** Nuxt.js modules
*/
modules: [
'@nuxtjs/axios',
[
'@nuxtjs/pwa',
{
manifest: false,
icon: false,
workbox: {
runtimeCaching: [
{
urlPattern: 'https://a.storyblok.com/.*',
handler: 'CacheFirst',
},
{
urlPattern: 'https://img2.storyblok.com/.*',
handler: 'CacheFirst',
},
{
urlPattern: 'https://cdn.sanity.io/.*',
handler: 'CacheFirst',
},
],
},
},
],
[
'storyblok-nuxt',
{
accessToken: process.env.STORYBLOK_ACCESS_TOKEN,
cacheProvider: 'memory',
},
],
'nuxt-webfontloader',
'portal-vue/nuxt',
'@nuxtjs/proxy',
'@nuxtjs/sentry',
],
...(isProd || isStaging
? {
sentry: {
dsn: process.env.SENTRY_DNS, // Enter your project's DSN here
// Additional Module Options go here
// https://sentry.nuxtjs.org/sentry/options
tracing: {
tracesSampleRate: isProd ? 0.2 : 1.0,
vueOptions: {
tracing: true,
tracingOptions: {
hooks: ['mount', 'update'],
timeout: 2000,
trackComponents: true,
},
},
browserOptions: {},
},
config: {
// Add native Sentry config here
// https://docs.sentry.io/platforms/javascript/guides/vue/configuration/options/
environment: isProd ? 'production' : 'staging',
debug: !isProd,
},
},
}
: {}),
...(!/prod/i.test(process.env.NODE_ENV) && !process.env.NETLIFY
? {
proxy: {
'/.netlify/functions': {
target: process.env.API_ORIGIN,
},
},
}
: {}),
...(/prod/i.test(process.env.NODE_ENV) || process.env.NETLIFY || process.env.HEROKU
? {}
: {
server: {
https: {
key: fs.readFileSync(path.resolve(__dirname, '.tls/key.pem')),
cert: fs.readFileSync(path.resolve(__dirname, '.tls/cert.pem')),
},
},
}),
axios: {
credentials: true,
baseURL: process.env.API_BASE_URL,
},
auth: {
cookie: {
cookie: {
name: 'frontend_love_account_state',
},
token: {
required: false,
type: false,
},
user: {
property: '',
},
endpoints: {
login: {
url: process.env.ACCOUNT_ENDPOINT_MAGIC_LINK_REQUEST,
method: 'post',
},
logout: { url: process.env.ACCOUNT_ENDPOINT_LOGOUT, method: 'post' },
user: { url: process.env.ACCOUNT_ENDPOINT_USER_INFO, method: 'get' },
},
},
loginCode: {
scheme: 'local',
token: {
required: false,
type: false,
},
endpoints: {
login: {
url: process.env.ACCOUNT_ENDPOINT_VERIFY_LOGINCODE,
method: 'post',
},
user: { url: process.env.ACCOUNT_ENDPOINT_USER_INFO, method: 'get' },
},
user: {
property: false,
autoFetch: false,
},
},
plugins: ['~/plugins/auth.js'],
},
/*
** nuxt-webfontloader Options
*/
webfontloader: {
google: {
families: ['Merriweather:300,400,700', 'Rubik:300,400,500', 'Odibee+Sans'],
},
},
/*
** Build configuration
*/
build: {
quiet: false,
/*
** You can extend webpack config here
*/
extend(config, ctx) {
config.resolve.alias.vue = 'vue/dist/vue.common'
if (ctx.isDev)
config.devtool = ctx.isClient ? 'source-map' : 'inline-source-map'
},
postcss: {
plugins: {
'postcss-import': {},
'tailwindcss/nesting': {},
'tailwindcss': {},
'autoprefixer': {},
},
},
transpile: ['@passionatepeople/sanity-utils', 'vue-pincode-input'],
},
generate: {
interval: 200,
routes: async() => {
if (!process.env.STATIC_HOST) {
// eslint-disable-next-line no-console
console.error('No STATIC_HOST variable specified!')
process.exit(1)
}
await getSitePayload(process.env.STATIC_HOST)
const { pages } = require('./dist/data.json')
// eslint-disable-next-line no-console
console.log('Explicit routes to generate:')
// eslint-disable-next-line no-console
pages.forEach(({ route }) => console.log(` - ${route}`))
return pages
},
fallback: true,
},
purgeCSS: {
paths: [
'components/**/*.vue',
'layouts/**/*.vue',
'pages/**/*.vue',
'plugins/**/*.js',
'dist/*.json',
],
whitelistPatterns: [/bg-/, /text-/, /from-/, /to-/, /border-/, /lyt-/, /w-/, /grid-cols-/],
extractors: [
{
extractor(content) {
return content.match(/[\w-.:!/]+(?<!:)/g)
},
extensions: ['html', 'vue', 'js', 'json'],
},
],
},
/*
** Storybook module configuration
** See https://storybook.nuxtjs.org/options/
*/
storybook: {
addons: ['@storybook/addon-controls/register', '@storybook/addon-viewport/register'],
},
watchers: {
webpack: {
ignored: [
'**/*.{md,log,prettierignore,prettierrc,stylelintignore,npmrc,gitignore}',
'**/.git/**',
],
},
},
}
}
Solution 1:[1]
Update
The actual issue was actually a version bump of ESlint from 1.x.x to 3.x.x. git bisect helped finding out the actual culprit!
Cloning the repo again and reinstalling the dependencies again, fixed all the above mentioned issues while running yarn dev!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
