.nuxt/client.js: Cannot find module ‘core-js-compat/data’ during build

Versions

  • nuxt: 2.14.8
  • node: v14.13.0

Reproduction

I’ve been trying to upgrade my nuxt dependency from 2.14.7 to 2.14.8 and I am getting an error while building the project through npm run build.

ERROR

Error: [BABEL] /project/.nuxt/client.js: Cannot find module ‘core-js-compat/data’

I tried many many things but I could not find the source of the issue, hopefully someone here might have an idea and help me out with that.

My package.json

{
    "name": "***",
    "version": "2.2.1",
    "private": true,
    "scripts": {
      "dev": "nuxt",
      "dev:network": "NUXT_HOST=0.0.0.0 NUXT_PORT=3333 nuxt",
      "build": "nuxt-ts build",
      "start": "nuxt-ts start",
      "export": "nuxt-ts export",
      "serve": "nuxt-ts serve",
      "lint:js": "eslint --ext .js,.ts,.vue --ignore-path .gitignore .",
      "lint:style": "stylelint **/*.{css,scss,vue} --ignore-path .gitignore",
      "lint": "npm run lint:js && npm run lint:style",
      "test": "jest",
      "release": "standard-version",
      "storybook": "nuxt storybook",
      "storybook:build": "nuxt storybook build",
      "postinstall": "patch-package"
    },
    "homepage": "https://github.com/***/***#readme",
    "repository": {
      "type": "git",
      "url": "git://github.com/***/***.git"
    },
    "bugs": {
      "url": "https://github.com/***/***/issues"
    },
    "engines": {
      "node": "14.5.x",
      "npm": "6.14.x"
    },
    "lint-staged": {
      "*.{ts,js,vue}": "eslint",
      "*.{css,scss,vue}": "stylelint"
    },
    "config": {
      "commitizen": {
        "path": "cz-conventional-changelog"
      }
    },
    "husky": {
      "hooks": {
        "pre-commit": "lint-staged",
        "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
      }
    },
    "dependencies": {
      "@nuxt/typescript-runtime": "^2.0.0",
      "@nuxtjs/auth": "^4.9.1",
      "@nuxtjs/axios": "^5.12.3",
      "@nuxtjs/composition-api": "^0.16.4",
      "@nuxtjs/pwa": "^3.3.2",
      "@nuxtjs/sentry": "^4.5.0",
      "@nuxtjs/toast": "^3.3.1",
      "awesome-phonenumber": "^2.42.0",
      "cookie-universal-nuxt": "^2.1.4",
      "core-js": "^3.8.1",
      "dayjs": "^1.9.7",
      "dinero.js": "^1.8.1",
      "graphql-tag": "^2.11.0",
      "js-cookie": "^2.2.1",
      "lazysizes": "^5.2.2",
      "lru-cache": "^6.0.0",
      "mixpanel-browser": "^2.40.0",
      "nuxt": "^2.14.11",
      "nuxt-i18n": "^6.15.4",
      "patch-package": "^6.2.2",
      "pusher-js": "^7.0.2",
      "ramda": "^0.27.1",
      "ramda-extension": "^0.10.3",
      "timezone-support": "^2.0.2",
      "vue-js-toggle-button": "^1.3.3",
      "vue-scrollto": "^2.20.0",
      "vue2-scrollspy": "^2.3.1",
      "vuex-persistedstate": "^3.1.0"
    },
    "devDependencies": {
      "@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
      "@babel/plugin-proposal-optional-chaining": "^7.12.7",
      "@commitlint/cli": "^11.0.0",
      "@commitlint/config-conventional": "^11.0.0",
      "@nuxt/types": "^2.14.10",
      "@nuxt/typescript-build": "^2.0.3",
      "@nuxtjs/eslint-config-typescript": "^5.0.0",
      "@nuxtjs/eslint-module": "^3.0.1",
      "@nuxtjs/laravel-echo": "^1.1.0",
      "@nuxtjs/router": "^1.5.0",
      "@nuxtjs/storybook": "^3.3.0",
      "@nuxtjs/stylelint-module": "^4.0.0",
      "@nuxtjs/tailwindcss": "^3.1.0",
      "@testing-library/jest-dom": "^5.11.6",
      "@types/faker": "^5.1.5",
      "@types/googlemaps": "^3.40.3",
      "@types/jest": "^26.0.15",
      "@types/nuxtjs__auth": "^4.8.5",
      "@vue/test-utils": "^1.1.1",
      "babel-core": "7.0.0-bridge.0",
      "babel-eslint": "^10.1.0",
      "babel-jest": "^26.6.3",
      "eslint": "^7.15.0",
      "eslint-config-prettier": "^7.0.0",
      "eslint-plugin-nuxt": "^2.0.0",
      "eslint-plugin-prettier": "^3.2.0",
      "factory.ts": "^0.5.1",
      "faker": "^5.1.0",
      "husky": "^4.3.5",
      "jest": "^26.6.3",
      "lint-staged": "^10.5.3",
      "node-sass": "^5.0.0",
      "nuxt-svg-loader": "^1.2.0",
      "nuxt-webfontloader": "^1.1.0",
      "prettier": "^2.2.1",
      "sass-loader": "^10.1.0",
      "shipit-cli": "^5.3.0",
      "shipit-deploy": "^5.3.0",
      "shipit-slack": "^0.1.3",
      "standard-version": "^9.0.0",
      "stylelint": "^13.8.0",
      "stylelint-config-prettier": "^8.0.1",
      "stylelint-config-standard": "^20.0.0",
      "stylelint-scss": "^3.18.0",
      "ts-jest": "^26.4.4",
      "vue-jest": "^3.0.7",
      "vuex-mock-store": "0.0.8"
    }
  }

Error

ERROR in ./.nuxt/client.js
Module build failed (from ./node_modules/@nuxt/webpack/node_modules/babel-loader/lib/index.js):
Error: [BABEL] /project/.nuxt/client.js: Cannot find module 'core-js-compat/data'
Require stack:
- /project/node_modules/@nuxt/babel-preset-app/src/index.js
- /project/node_modules/@nuxt/webpack/node_modules/@babel/core/lib/config/files/plugins.js
- /project/node_modules/@nuxt/webpack/node_modules/@babel/core/lib/config/files/index.js
- /project/node_modules/@nuxt/webpack/node_modules/@babel/core/lib/index.js
- /project/node_modules/@nuxt/webpack/node_modules/babel-loader/lib/index.js
- /project/node_modules/loader-runner/lib/loadLoader.js
- /project/node_modules/loader-runner/lib/LoaderRunner.js
- /project/node_modules/webpack/lib/NormalModule.js
- /project/node_modules/webpack/lib/NormalModuleFactory.js
- /project/node_modules/webpack/lib/Compiler.js
- /project/node_modules/webpack/lib/webpack.js
- /project/node_modules/@nuxt/webpack/dist/webpack.js
- /project/node_modules/@nuxt/cli/dist/cli-index.js
- /project/node_modules/@nuxt/cli/dist/cli.js
- /project/node_modules/@nuxt/typescript-runtime/bin/nuxt-ts.js (While processing: "/project/node_modules/@nuxt/babel-preset-app/src/index.js")
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:747:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at getPolyfills (/project/node_modules/@nuxt/babel-preset-app/src/index.js:44:24)
    at module.exports (/project/node_modules/@nuxt/babel-preset-app/src/index.js:107:10)
    at /project/node_modules/@nuxt/webpack/node_modules/@babel/core/lib/config/full.js:211:14
    at Generator.next (<anonymous>)
    at Function.<anonymous> (/project/node_modules/@nuxt/webpack/node_modules/@babel/core/lib/gensync-utils/async.js:26:3)
    at Generator.next (<anonymous>)
    at step (/project/node_modules/gensync/index.js:254:32)
    at evaluateAsync (/project/node_modules/gensync/index.js:284:5)
    at Function.errback (/project/node_modules/gensync/index.js:108:7)
    at errback (/project/node_modules/@nuxt/webpack/node_modules/@babel/core/lib/gensync-utils/async.js:70:18)
    at async (/project/node_modules/gensync/index.js:183:31)
    at onFirstPause (/project/node_modules/gensync/index.js:209:13)
 @ multi ./node_modules/url-polyfill/url-polyfill.min.js ./.nuxt/client.js app[1]

 FATAL  Nuxt build error                                                                                    10:16:39

  at WebpackBundler.webpackCompile (node_modules/@nuxt/webpack/dist/webpack.js:5502:21)
  at processTicksAndRejections (internal/process/task_queues.js:93:5)
  at WebpackBundler.build (node_modules/@nuxt/webpack/dist/webpack.js:5451:5)
  at Builder.build (node_modules/@nuxt/builder/dist/builder.js:5634:5)
  at Object.run (node_modules/@nuxt/cli/dist/cli-build.js:109:7)
  at NuxtCommand.run (node_modules/@nuxt/cli/dist/cli-index.js:2803:7)


   ╭─────────────────────────────╮
   │                             │
   │   ✖ Nuxt Fatal Error        │
   │                             │
   │   Error: Nuxt build error   │
   │                             │
   ╰─────────────────────────────╯

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ***@2.2.1 build: `nuxt-ts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ***@2.2.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/.npm/_logs/2020-12-13T06_16_39_288Z-debug.log

NOTE: I tried in a fresh nuxt app, including all my dependencies to reproduce the error in an open repo but it doesn’t happen, it only happens on my project, so I could not provide a link to reproduce the error.

1 possible answer(s) on “.nuxt/client.js: Cannot find module ‘core-js-compat/data’ during build

  1. That is it! Once again you saved my life 🥇

    I tried deleting the node_modules before but it didn’t work.
    The problem was that the package-lock.json was locking the version of the core-js-compat for some mistake I did in the past probably =)

    Thanks again @danielroe !