Nuxt ошибка 500

I was working on a Nuxt.js project and everything was working perfectly, then suddenly the npm run dev failed. I tried to run it again and I am constantly getting this error:

 FATAL  Request failed with status code 500                                                                                          17:43:55

  at createError (node_modules/axios/lib/core/createError.js:16:15)
  at settle (node_modules/axios/lib/core/settle.js:18:12)
  at IncomingMessage.handleStreamEnd (node_modules/axios/lib/adapters/http.js:201:11)
  at IncomingMessage.emit (events.js:194:15)
  at IncomingMessage.EventEmitter.emit (domain.js:441:20)
  at endReadableNT (_stream_readable.js:1125:12)
  at process._tickCallback (internal/process/next_tick.js:63:19)


   ╭────────────────────────────────────────────────╮
   │                                                │
   │   ✖ Nuxt Fatal Error                           │
   │                                                │
   │   Error: Request failed with status code 500   │
   │                                                │
   ╰────────────────────────────────────────────────╯

npm ERR! code ELIFECYCLE
npm ERR! errno 1

I tried some typical solutions like removing the node_modules and .nuxt directories and installing the dependencies again, and went even further and re-installed nodejs but non of them worked. It is really strange since it happened suddenly while I wasn’t actually changing anything on the code, however I even recovered the latest working version of the app just to be sure, but that didn’t help either. Whatever is it, is not related to the project codes since the same code was working before without any error.

asked May 24, 2019 at 16:02

Torgheh's user avatar

3

I found the solution myself and I share it so no one else has to spend half a day figuring what is wrong.

Solution

A failed axios request inside the nuxt.config.js has caused this problem. So find the reason why the axios request throws the error, which is most probably because of a change in the api you are trying to call.

answered May 24, 2019 at 22:28

Torgheh's user avatar

TorghehTorgheh

7768 silver badges18 bronze badges

1

Reproduction: https://stackblitz.com/edit/nuxt-starter-ykdhnn?file=nuxt.config.ts (hacky, see notes).

I started running into this issue quite a bit, I believe it’s related to Nitro v2 and did some digging today.

For me, what I’ve found is that this occurs when your workspace directory is being transpiled.

I have a replication with my nuxt-og-image repo: https://github.com/harlan-zw/nuxt-og-image/tree/temp/bugged-playground (pnpm i && pnpm run dev)

My setup is a playground directory as a subfolder of a module. The playground links the module using a link in package.json

export default defineNuxtConfig({
  modules: [
    'nuxt-og-image',
  ],
})
{
  "dependencies": {
    "nuxt-og-image": "link:../"
  }
}

With my setup it seems like a deeper issue with the node module resolution, pointing to the directory with the package.json instead of the /dist folder, leading it to inline vue again?

The issue was pretty easy to solve in this case, by swapping to a directory path instead of relying on the node module resolving. Don’t think it helps OP in this case.

export default defineNuxtConfig({
  modules: [
    resolve(__dirname, '../src/module'),
  ],
})

I tried to replication this in StackBlitz without much success using a similar setup as the above. I had to just manually point to the workspace dir to be transpiled and I could replicate it, see reproduction.

So in summary, I believe this is a Nitro issue with the inlining of deps, possibly module resolution issue (possibly with symlinks?). Related code would be this function https://github.com/unjs/nitro/blob/main/src/rollup/plugins/externals.ts#LL22C19-L22C19

@pi0 might have some ideas

I was working on a Nuxt.js project and everything was working perfectly, then suddenly the npm run dev failed. I tried to run it again and I am constantly getting this error:

 FATAL  Request failed with status code 500                                                                                          17:43:55

  at createError (node_modules/axios/lib/core/createError.js:16:15)
  at settle (node_modules/axios/lib/core/settle.js:18:12)
  at IncomingMessage.handleStreamEnd (node_modules/axios/lib/adapters/http.js:201:11)
  at IncomingMessage.emit (events.js:194:15)
  at IncomingMessage.EventEmitter.emit (domain.js:441:20)
  at endReadableNT (_stream_readable.js:1125:12)
  at process._tickCallback (internal/process/next_tick.js:63:19)


   ╭────────────────────────────────────────────────╮
   │                                                │
   │   ✖ Nuxt Fatal Error                           │
   │                                                │
   │   Error: Request failed with status code 500   │
   │                                                │
   ╰────────────────────────────────────────────────╯

npm ERR! code ELIFECYCLE
npm ERR! errno 1

I tried some typical solutions like removing the node_modules and .nuxt directories and installing the dependencies again, and went even further and re-installed nodejs but non of them worked. It is really strange since it happened suddenly while I wasn’t actually changing anything on the code, however I even recovered the latest working version of the app just to be sure, but that didn’t help either. Whatever is it, is not related to the project codes since the same code was working before without any error.

asked May 24, 2019 at 16:02

Torgheh's user avatar

3

I found the solution myself and I share it so no one else has to spend half a day figuring what is wrong.

Solution

A failed axios request inside the nuxt.config.js has caused this problem. So find the reason why the axios request throws the error, which is most probably because of a change in the api you are trying to call.

answered May 24, 2019 at 22:28

Torgheh's user avatar

TorghehTorgheh

7768 silver badges18 bronze badges

1

I recently updated some dependencies in my Nuxt app, and now I’m unable to start the app. When I try to access the app at localhost:3000, I receive a 500 error. However, when I check the server console in my terminal, I don’t see any errors being thrown.

The error message I’m seeing in the browser console is:

500
[vite-node] [plugin:vite:import-analysis] [VITE_ERROR] /@fs./node_modules/nuxt/dist/app/entry.mjs

import { createSSRApp, createApp, nextTick } from "vue";
import { $fetch } from "ofetch";
import { baseURL } from "#build/paths.mjs";
import { createNuxtApp, applyPlugins, normalizePlugins } from "#app";
import "#build/css";
import _plugins from "#build/plugins";
import RootComponent from "#build/root-component.mjs";
import { appRootId } from "#build/nuxt.config.mjs";
if (!globalThis.$fetch) {
  globalThis.$fetch = $fetch.create({
    baseURL: baseURL()
  });
}
let entry;
const plugins = normalizePlugins(_plugins);
if (true) {
  entry = async function createNuxtAppServer(ssrContext) {
    const vueApp = createApp(RootComponent);
    const nuxt = createNuxtApp({ vueApp, ssrContext });
    try {
      await applyPlugins(nuxt, plugins);
      await nuxt.hooks.callHook("app:created", vueApp);
    } catch (err) {
      await nuxt.callHook("app:error", err);
      nuxt.payload.error = nuxt.payload.error || err;
    }
    return vueApp;
  };
}
if (false) {
  if (true && import.meta.webpackHot) {
    import.meta.webpackHot.accept();
  }
  entry = async function initApp() {
    const isSSR = Boolean(window.__NUXT__?.serverRendered);
    const vueApp = isSSR ? createSSRApp(RootComponent) : createApp(RootComponent);
    const nuxt = createNuxtApp({ vueApp });
    try {
      await applyPlugins(nuxt, plugins);
    } catch (err) {
      await nuxt.callHook("app:error", err);
      nuxt.payload.error = nuxt.payload.error || err;
    }
    try {
      await nuxt.hooks.callHook("app:created", vueApp);
      await nuxt.hooks.callHook("app:beforeMount", vueApp);
      vueApp.mount("#" + appRootId);
      await nuxt.hooks.callHook("app:mounted", vueApp);
      await nextTick();
    } catch (err) {
      await nuxt.callHook("app:error", err);
      nuxt.payload.error = nuxt.payload.error || err;
    }
  };
  entry().catch((error) => {
    console.error("Error while mounting app:", error);
  });
}
export default (ctx) => entry(ctx);

at /@fs./node_modules/nuxt/dist/app/entry.mjs

This is my package.json:

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "devDependencies": {
    "@nuxtjs/i18n": "^8.0.0-beta.6",
    "@nuxtjs/pwa": "^3.3.5",
    "@nuxtjs/supabase": "^0.3.1",
    "autoprefixer": "^10.4.13",
    "nuxt": "3.0.0",
    "postcss": "^8.4.19",
    "sass": "^1.56.1",
    "tailwindcss": "^3.2.4"
  },
  "dependencies": {
    "@formkit/addons": "^0.16.5",
    "@formkit/nuxt": "^0.16.5",
    "@formkit/tailwindcss": "^0.16.5",
    "@formkit/themes": "^0.16.5",
    "@fortawesome/fontawesome-svg-core": "^6.2.1",
    "@fortawesome/free-brands-svg-icons": "^6.2.1",
    "@fortawesome/free-solid-svg-icons": "^6.2.1",
    "@fortawesome/vue-fontawesome": "^3.0.2",
    "@hcaptcha/vue-hcaptcha": "^0.3.2",
    "@nuxtjs/algolia": "^1.5.0",
    "@nuxtjs/tailwindcss": "^6.1.3",
    "@tailwindcss/forms": "^0.5.3",
    "@vueuse/motion": "^2.0.0-beta.12",
    "i18n-iso-countries": "^7.5.0",
    "is-eu-member": "^1.0.6",
    "maska": "^2.1.7",
    "tailwind-css-variables": "^3.0.1",
    "tailwindcss-hyphens": "^0.1.0",
    "trie-search": "^1.3.6",
    "vue-number-animation": "^1.1.2",
    "vue-tailwind-datepicker": "^1.3.2",
    "vue-uuid": "^3.0.0"
  }
}

This is my nuxt.config.ts:

import postcss from './config/postcss'

export default defineNuxtConfig({
    app: {
        pageTransition: { name: 'page', mode: 'out-in' },
    },
    pwa: {
        manifest: {
            name: 'RightsPlus',
            description: "Fluggastrechte",
            theme_color: '#f97316',
            short_name: 'RightsPlus'
        }
    },
    modules: [
        '@nuxtjs/algolia',
        '@nuxtjs/i18n',
        '@formkit/nuxt',
        '@nuxtjs/supabase',
    ],
    buildModules: [
        '@nuxtjs/pwa',
    ],
    nitro: {
        compressPublicAssets: true,
    },
    formkit: {
        configFile: '~/formkit.config.ts',
    },
    css: [
        '~/assets/css/main.scss',
        '~/assets/css/transitions.css',
        '@fortawesome/fontawesome-svg-core/styles.css'
    ],
    i18n: {
        vueI18n: './i18n.config.ts' // if you are using custom path, default 
    },
    postcss,
    sourcemap: {
        server: process.env.NODE_ENV === 'development',
        client: process.env.NODE_ENV === 'development',
    },
    runtimeConfig: {
        public: {
            google: {
                key: process.env.GOOGLE_KEY,
                placeId: process.env.GOOGLE_PLACE_ID
            },
            flight: {
                aviationstack: process.env.AVIATIONSTACK_KEY,
                flighlabs: process.env.FLIGHTLABS_KEY,
                key: process.env.APP_KEY,
                appId: process.env.APP_ID
            }
        },
    }
})

Anyone got a hunch as to where to start looking?

catalog

1、 Source of the problem

2、 Solutions

3、 Solutions

4、 Summary


1、 Source of the problem

Usually using nuxt and deploying it online are normal, and occasionally 500 errors are reported one day;

Nuxt.js The operation ( NPM run dev ) reported the following error:

The server error log is as follows:

0|qiu  |  ERROR  Request failed with status code 500                           20:17:14
0|qiu  |   at createError (node_modules/axios/lib/core/createError.js:16:15)
0|qiu  |   at settle (node_modules/axios/lib/core/settle.js:18:12)
0|qiu  |   at IncomingMessage.handleStreamEnd (node_modules/axios/lib/adapters/http.js:201:11)
0|qiu  |   at IncomingMessage.emit (events.js:187:15)
0|qiu  |   at IncomingMessage.EventEmitter.emit (domain.js:441:20)
0|qiu  |   at endReadableNT (_stream_readable.js:1094:12)
0|qiu  |   at process._tickCallback (internal/process/next_tick.js:63:19)

2、 Solutions

500 status code: server internal error, unable to complete the request.

Generally speaking, this problem occurs when the server code fails

So the problem lies in the back end, check the interface

3、 Solutions

Annotate the code one by one, and find an interface error in the page, so that the problem can be solved after the back-end correction;

The error of the request interface is as follows (PHP in the background)

 

It’s a clumsy way to comment the code one by one. If you can, you can directly look at the network of the console to see the interface in error;


4、 Summary

because Nuxt.js It is a framework for server-side rendering. As long as an interface in the page reports an error and the server returns an error, the front-end display page will crash;

And an interface error, nuxt only returns 500 errors, can’t directly locate the problem, need to check one by one, hope nuxt is more and more powerful

The wechat app I developed (online):
if you are interested, you can have a look at it and pay close attention to it with one click. Thank you ~
1. Xiaolv depression Test Assistant (wechat APP): a completely free and ad free depression self-test app, which collects questionnaires from global authorities and provides them to you for free. There are novel score records and posters to share, You can see and learn!

Xiaolv depression test assistant

Read More:

Понравилась статья? Поделить с друзьями:
  • Numpy среднеквадратичная ошибка
  • Numpy ndarray object is not callable ошибка
  • Ntdsutil ошибка при синтаксическом разборе ввода неправильный синтаксис
  • Numplate light ошибка bmw
  • Ntdll dll ошибка windows 7 x64