Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuxt js high CPU usage in dev environment

Since few updates my app front part in docker container doesn't work well It use above 100% of Docker CPU, 60/70% of my laptop CPU (fans run at 100%) And the HMR is very slow

This issue doesn't appear on production and on others laptops

I tried many things from different forums similar issues but nothing work

I reseted Docker to factory defaults settings, allowed more memory and CPU I updated my dependencies I removed and restored my node modules

I don't know what i should check to fix this issue

MacOS Catalina 10.15.4

Node v13.12.0

My package.json

{
  "name": "front",
  "version": "1.0.1",
  "description": "My first-class Nuxt.js project",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "HOST=0.0.0.0 PORT=8080 nuxt start",
    "generate": "nuxt generate",
    "lint": "eslint --ext .js,.vue .",
    "precommit": "npm run lint"
  },
  "config": {
    "nuxt": {
      "host": "0.0.0.0",
      "port": "8080"
    }
  },
  "dependencies": {
    "@fullcalendar/core": "^4.3.1",
    "@fullcalendar/daygrid": "^4.3.0",
    "@fullcalendar/interaction": "^4.3.0",
    "@fullcalendar/timegrid": "^4.3.0",
    "@fullcalendar/vue": "^4.3.1",
    "@nuxt/webpack": "^2.11.0",
    "@nuxtjs/auth": "^4.5.3",
    "@nuxtjs/axios": "^5.4.1",
    "@nuxtjs/google-analytics": "^2.2.0",
    "@nuxtjs/google-tag-manager": "^2.1.4",
    "@nuxtjs/gtm": "^2.2.3",
    "@nuxtjs/pwa": "^2.6.0",
    "@nuxtjs/robots": "^2.0.0",
    "@nuxtjs/router": "^1.3.2",
    "@nuxtjs/sitemap": "^0.2.2",
    "algoliasearch": "^4.1.0",
    "cross-env": "^5.2.0",
    "cxlt-vue2-toastr": "^1.1.0",
    "date-fns": "^1.30.1",
    "debug": "^4.1.1",
    "gsap": "^2.1.3",
    "jquery": "^3.4.1",
    "libphonenumber-js": "^1.7.14",
    "moment": "^2.24.0",
    "node-sass": "^4.13.1",
    "nuxt": "^2.11.0",
    "nuxt-facebook-pixel-module": "^1.3.0",
    "nuxt-google-maps-module": "^1.6.0",
    "nuxt-jsonld": "^1.4.5",
    "nuxt-token-auth": "^1.0.2",
    "nuxt-user-agent": "^1.2.2",
    "sass-loader": "^7.1.0",
    "vee-validate": "^2.2.0",
    "vue": "^2.6.11",
    "vue-gallery": "^2.0.0",
    "vue-i18n": "^8.10.0",
    "vue-infinite-scroll": "^2.0.2",
    "vue-instantsearch": "^2.7.0",
    "vue-js-modal": "^1.3.33",
    "vue-lazyload": "^1.2.6",
    "vue-mq": "^1.0.1",
    "vue-multiselect": "^2.1.6",
    "vue-read-more": "^1.1.1",
    "vue-scrollto": "^2.15.0",
    "vue-sticky": "^3.3.4",
    "vue-tawk": "^1.0.1",
    "vue-upload-component": "^2.8.20",
    "vue-wait": "^1.3.3",
    "vue2-dropzone": "^3.5.8",
    "vue2-leaflet": "^1.2.3",
    "vuedraggable": "^2.20.0",
    "vuejs-datepicker": "^1.5.4",
    "vuejs-paginate": "^2.1.0",
    "vueperslides": "^2.7.0"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.1",
    "eslint": "^5.16.0",
    "eslint-config-standard": "^12.0.0",
    "eslint-loader": "^2.1.2",
    "eslint-plugin-import": "^2.16.0",
    "eslint-plugin-node": "^8.0.1",
    "eslint-plugin-promise": "^4.0.1",
    "eslint-plugin-standard": "^4.0.0",
    "eslint-plugin-vue": "^4.7.1",
    "nodemon": "^1.18.10"
  }
}
like image 447
Wako Avatar asked May 20 '20 10:05

Wako


1 Answers

Probably problem with the webpack's watch mode. As stated here:

For some systems, watching many file systems can result in a lot of CPU or memory usage. It is possible to exclude a huge folder like node_modules

module.exports = {
  //...
  watchOptions: {
    ignored: /node_modules/
  }
};

In your case (nuxt.js), just add to nuxt.config.js

 watchers: {
    webpack: {
      ignored: /node_modules/
    }
  }
like image 61
Svetljo Avatar answered Sep 19 '22 15:09

Svetljo