Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR in ./.nuxt/axios.js Module not found: Error: Can't resolve 'axios' in '.nuxt' #701

Open
learntheropes opened this issue Aug 24, 2022 · 0 comments

Comments

@learntheropes
Copy link

Suddenly I get this error when I deploy on Vercel:

[log]  ----------------- Nuxt build ----------------- 
[log] Running nuxt build --standalone --no-lock --config-file "nuxt.config.js" /vercel/path0
[fatal] Nuxt build error
  ERROR in ./.nuxt/axios.js
  Module not found: Error: Can't resolve 'axios' in '.nuxt'
  @ ./.nuxt/axios.js 25:0-26 111:14-19 112:22-27 113:19-24 203:8-13
  @ ./.nuxt/index.js
  @ ./.nuxt/client.js
  @ multi ./node_modules_dev/@nuxt/components/lib/installComponents.js ./.nuxt/client.js
  
  ERROR in ./plugins/imagekit.js
  Module not found: Error: Can't resolve 'axios' in 'plugins'
  @ ./plugins/imagekit.js 6:0-26 44:23-28
  @ ./.nuxt/index.js
  @ ./.nuxt/client.js
  @ multi ./node_modules_dev/@nuxt/components/lib/installComponents.js ./.nuxt/client.js
   ╭─────────────────────────────╮
   │                                                                          │
   │   ✖ Nuxt Fatal Error                                          │
   │                                                                          │
   │   Error: Nuxt build error                                    │
   │                                                                          │
   ╰─────────────────────────────╯
Error! Command failed with exit code 1: npx nuxt build --standalone --no-lock --config-file "nuxt.config.js" /vercel/path0

I tried to remove the node_modules folder and package-lock.json file and npm install, however the problem is not locally but only on build on deployment.

To fix it, I had to install axios on top of @nuxtjs/axios

What can be the issue?

My package.json

{
  "name": "promotoras-paraguay",
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start"
  },
  "dependencies": {
    "@aws-sdk/client-rekognition": "^3.127.0",
    "@mdi/font": "^6.7.96",
    "@nuxt/content": "^1.15.1",
    "@nuxtjs/auth-next": "^5.0.0-1648802546.c9880dc",
    "@nuxtjs/axios": "^5.13.6",
    "@nuxtjs/device": "^2.1.0",
    "@nuxtjs/i18n": "^7.2.2",
    "@nuxtjs/moment": "^1.6.1",
    "@nuxtjs/sitemap": "^2.4.0",
    "axios": "^0.27.2",
    "body-parser": "^1.20.0",
    "express": "^4.18.1",
    "express-async-handler": "^1.2.0",
    "faunadb": "^4.5.4",
    "i18n-iso-countries": "^7.4.0",
    "imagekit": "^3.2.5",
    "jsonwebtoken": "^8.5.1",
    "lodash.clonedeep": "^4.5.0",
    "lodash.filter": "^4.6.0",
    "lodash.find": "^4.6.0",
    "lodash.findindex": "^4.6.0",
    "lodash.indexof": "^4.0.5",
    "lodash.maxby": "^4.6.0",
    "lodash.merge": "^4.6.2",
    "lodash.minby": "^4.6.0",
    "lodash.remove": "^4.7.0",
    "lodash.shuffle": "^4.2.0",
    "lodash.sortby": "^4.7.0",
    "lodash.uniqby": "^4.7.0",
    "nodemailer": "^6.7.8",
    "nuxt": "^2.15.8",
    "nuxt-buefy": "^0.4.23",
    "nuxt-validate": "^1.0.1",
    "uuid": "^8.3.2",
    "vue-auth-image": "^0.0.3",
    "vue-shortkey": "^3.1.7",
    "vue2-hammer": "^2.1.2"
  },
  "devDependencies": {
    "@nuxtjs/google-analytics": "^2.4.0",
    "sass": "^1.52.1",
    "sass-loader": "^10.2.1"
  }
}

and my nuxt.config.js

import { locales, validate, getRoutes } from './assets/js/locales'
import dotenv from 'dotenv'
dotenv.config()

export default {

  target: "server",
  ssr: "true",

  head() {
    const i18nHead = this.$nuxtI18nHead ? this.$nuxtI18nHead({ addSeoAttributes: true }) : {}
    return {
      htmlAttrs: {
        ...i18nHead.htmlAttrs
      },
      meta: [
        {
          charset: 'utf-8'
        },
        {
          hid: 'viewport',
          name: 'viewport',
          content: 'width=device-width, initial-scale=1'
        },
        {
          hid: 'title',
          name: 'title',
          content: 'Promotoras Paraguay'
        },
        // {
        //   hid: 'geo.region',
        //   name: 'geo.region',
        //   content: 'Paraguay'
        // },
        // {
        //   hid: 'geo.placename',
        //   name: 'geo.placename',
        //   content: 'Asunción'
        // },
        {
          hid: 'googlebot',
          name: 'googlebot',
          content: 'notranslate'
        },
        ...i18nHead.meta
      ],
      link: [
        {
          rel: 'icon',
          type: 'image/x-icon',
          href: '/favicon.ico'
        },
        ...i18nHead.link
      ]
    }
  },

  env: {
    WA_BOT_URL: process.env.WA_BOT_URL,
    AUTH0_URL: process.env.AUTH0_URL,
    IMAGEKIT_PUBLIC_KEY: process.env.IMAGEKIT_PUBLIC_KEY
  },

  loading: { color: '#fff' },

  css: [
    '~/assets/scss/main.scss',
    "@mdi/font/css/materialdesignicons.css"
  ],

  components: {
    dirs: [
      '~/components',
      {
        path  : '~/components/layout',
        prefix: 'Layout'
      },
      {
        path  : '~/components/index',
        prefix: 'Index'
      },
      {
        path  : '~/components/hostess',
        prefix: 'Hostess'
      },
      {
        path  : '~/components/emojis',
        prefix: 'Emojis'
      },
      {
        path  : '~/components/account',
        prefix: 'Account'
      }
    ]
  },

  buildModules: [
    ['@nuxtjs/google-analytics', {
      id: process.env.GOOGLE_ANALYTICS_ID
    }]
  ],

  modules: [
    ['nuxt-buefy', {
      defaultIconPack: 'mdi',
      materialDesignIcons: false,
      materialDesignIconsHRef: '/',
      css: false
    }],

    ['@nuxt/content'],

    ['@nuxtjs/auth-next', {
      redirect: {
        callback: '/cb/',
        login: '/',
        home: '/account'
      },
      strategies: {
        auth0: {
          domain: process.env.AUTH0_URL,
          clientId: process.env.AUTH0_CLIENT_ID,
          audience: `https://${process.env.AUTH0_URL}/api/v2/`,
          scope: ['offline'],
          accessType: 'offline',
          responseType: 'code',
          grantType: 'authorization_code',
          codeChallengeMethod: 'S256',
          rewriteRedirects: true,
          logoutRedirectUri: (process.env.URL) ? `https://${process.env.URL}/` : 'http://localhost:3000/'
        }
      },
      plugins: [
        '~/plugins/auth.js'
      ]
    }],

    ['@nuxtjs/axios', {
      debug: (process.env.URL) ? false : true,
      baseURL:  (process.env.URL) ? `https://${process.env.URL}` : 'http://localhost:3000',
      proxyHeaders: true
    }],

    ['nuxt-validate',{
      lang: 'es',
      nuxti18n: {
        locale: validate
      }
    }],

    ['@nuxtjs/i18n', {
      baseUrl: (process.env.URL) ? `https://${process.env.URL}` : 'http://localhost:3000',
      locales: locales,
      detectBrowserLanguage: {
        useCookie: true,
        cookieKey: 'i18n_lang',
        fallbackLocale: 'es',
      },
      strategy: 'prefix',
      defaultLocale: 'es',
      lazy: true,
      langDir: 'lang/',
    }],

    ['@nuxtjs/moment', {
      timezone: true,
      locales: ['es', 'pt']
    }],

    ['@nuxtjs/sitemap', {
      hostname: (process.env.URL) ? `https://${process.env.URL}` : 'http://localhost:3000',
      defaults: {
        changefreq: 'daily',
        priority: 1,
        lastmod: new Date()
      },
      routes () {
        return getRoutes()
      },
      exclude: [
        '/cb',,
        '**/bookmarks',
        '**/login-disabled',
        '**/account',
        '**/account/**'
      ],        
    }],

    ['@nuxtjs/device']
  ],
      
  plugins: [
    { src: '@/plugins/vue-shortkey.js', mode: 'client' },
    { src: '@/plugins/vue-hammer.js', mode: 'client' },
    '~/plugins/moment.js',
    '~/plugins/validate.js',
    '~/plugins/imagekit.js',
    '~/plugins/country-codes.js',
    '~/plugins/utils.js',
    '~/plugins/pre-cache.js'
  ],

  serverMiddleware: process.env.URL ? [
    '~/middleware/response-header.js'
  ] : [
    '~/rest/admin/auth',
    '~/rest/admin/hostess/age',
    '~/rest/admin/approve',
    '~/rest/admin/payments.js',
    '~/rest/admin/payment.js',
    '~/rest/rekognition/compare.js',
    '~/rest/vision/ocr.js',
    '~/rest/translation/detect.js',
    '~/rest/translation/translate.js',
    '~/rest/account/age.js',
    '~/rest/account/publication.js',
    '~/rest/account/payments.js',
    '~/rest/account/payment.js',
    '~/rest/image/signature.js',
    '~/rest/wa/status.js',
    '~/rest/wa/code/send.js',
    '~/rest/wa/code/verify.js',
    '~/rest/wa/ip.js',
    '~/img/preview.js',
    '~/img/modal.js',
    '~/img/thumbnail.js',
    '~/img/video.js',
    '~/img/account.js',
    '~/img/clean.js'
  ],

  // build: {
  //   quiet: false,
  //   analyze: true
  // }
}

What can be the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant