Nuxt build locally but fails on vercel ERROR in ./node_modules_dev/pathe/dist/index.cjs 174:43

Viewed 34

I am trying to deploy my nuxt ssr app to vercel , i run npm run build locally it builds successfully but when i deploy it on vercel it gives me error i already tryed to comment buildModules(composition-api) , but it gives me new error on Pinia for example

nuxt.config.js

export default {
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'v-gestionFinance',
    htmlAttrs: {
      lang: 'en'
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },
  
  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
  ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
    '@/plugins/view-ui',
    { src: '~/plugins/vue-datepicker', ssr: false },
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/tailwindcss
    '@nuxtjs/tailwindcss',
    '@nuxtjs/composition-api/module',
    '@pinia/nuxt',
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    '@nuxtjs/axios',
    '@nuxtjs/auth-next',
    '@nuxtjs/proxy'
  ],

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    extend (config) {
      config.module.rules.push({
        test: /\.mjs$/,
        include: /node_modules/,
        type: "javascript/auto"
      })
    }
  }
}


vercel.json

{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder"
    }
  ]
}

package.json

{
  "name": "v-gestion-finance-v2",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "test": "jest"
  },
  "dependencies": {
    
  },
  "devDependencies": {
    "@nuxtjs/tailwindcss": "^4.2.1",
    "@pinia/testing": "0.0.13",
    "@vue/test-utils": "^1.3.0",
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "^27.4.4",
    "jest": "^27.4.4",
    "postcss": "^8.4.4",
    "vue-jest": "^3.0.4",
    "@nuxt/http": "^0.6.4",
    "@nuxtjs/auth-next": "5.0.0-1648802546.c9880dc",
    "@nuxtjs/axios": "^5.13.6",
    "@nuxtjs/composition-api": "^0.33.0",
    "@nuxtjs/proxy": "^2.1.0",
    "@pinia/nuxt": "^0.2.1",
    "@privyid/nuxt-csrf": "^1.0.0",
    "@vueuse/core": "^9.1.0",
    "axios": "^0.27.2",
    "chart.js": "^2.9.4",
    "core-js": "^3.19.3",
    "moment": "^2.29.4",
    "nuxt": "^2.15.8",
    "pinia": "^2.0.17",
    "vue": "^2.6.14",
    "vue-chartjs": "^4.1.1",
    "vue-server-renderer": "^2.6.14",
    "vue-template-compiler": "^2.6.14",
    "vuejs-datepicker": "^1.6.2",
    "webpack": "^4.46.0"
  }
}

Here is the log files

[00:46:44.481] Cloning github.com/vGestionFinance-v2 (Branch: main, Commit: 00ac5c3)
[00:46:45.036] Cloning completed: 554.561ms
[00:46:46.662] Looking up build cache...
[00:46:46.961] Build Cache not found
[00:46:47.176] Running "vercel build"
[00:46:47.672] Vercel CLI 28.2.0
[00:46:47.766] WARN! Due to `builds` existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings
[00:46:48.132] yarn add v1.22.17
[00:46:48.154] info No lockfile found.
[00:46:48.174] [1/4] Resolving packages...
[00:46:49.224] [2/4] Fetching packages...
[00:46:50.192] [3/4] Linking dependencies...
[00:46:50.528] [4/4] Building fresh packages...
[00:46:50.533] success Saved lockfile.
[00:46:50.539] success Saved 63 new dependencies.
[00:46:50.539] info Direct dependencies
[00:46:50.540] ├─ @nuxtjs/vercel-builder@0.22.1
[00:46:50.540] └─ @vercel/build-utils@5.4.1
[00:46:50.540] info All dependencies
[00:46:50.540] ├─ @nuxtjs/vercel-builder@0.22.1
[00:46:50.540] ├─ @nuxtjs/web-vitals@0.1.10
[00:46:50.540] ├─ @vercel/build-utils@5.4.1
[00:46:50.540] ├─ @vercel/node-bridge@2.1.0
[00:46:50.540] ├─ ansi-regex@5.0.1
[00:46:50.541] ├─ ansi-styles@4.3.0
[00:46:50.541] ├─ at-least-node@1.0.0
[00:46:50.541] ├─ balanced-match@1.0.2
[00:46:50.541] ├─ brace-expansion@1.1.11
[00:46:50.541] ├─ chalk@4.1.2
[00:46:50.541] ├─ cliui@7.0.4
[00:46:50.541] ├─ color-convert@2.0.1
[00:46:50.541] ├─ color-name@1.1.4
[00:46:50.541] ├─ concat-map@0.0.1
[00:46:50.541] ├─ consola@2.15.3
[00:46:50.541] ├─ cross-spawn@7.0.3
[00:46:50.541] ├─ destr@1.1.1
[00:46:50.542] ├─ emoji-regex@8.0.0
[00:46:50.542] ├─ escalade@3.1.1
[00:46:50.542] ├─ execa@5.1.1
[00:46:50.542] ├─ flat@5.0.2
[00:46:50.542] ├─ fs-extra@9.1.0
[00:46:50.542] ├─ fs.realpath@1.0.0
[00:46:50.542] ├─ get-caller-file@2.0.5
[00:46:50.542] ├─ get-stream@6.0.1
[00:46:50.542] ├─ glob@7.2.3
[00:46:50.542] ├─ graceful-fs@4.2.10
[00:46:50.542] ├─ has-flag@4.0.0
[00:46:50.542] ├─ human-signals@2.1.0
[00:46:50.542] ├─ inflight@1.0.6
[00:46:50.542] ├─ inherits@2.0.4
[00:46:50.542] ├─ is-fullwidth-code-point@3.0.0
[00:46:50.543] ├─ is-stream@2.0.1
[00:46:50.543] ├─ isexe@2.0.0
[00:46:50.543] ├─ jiti@1.14.0
[00:46:50.543] ├─ jsonfile@6.1.0
[00:46:50.543] ├─ lru-cache@6.0.0
[00:46:50.543] ├─ merge-stream@2.0.0
[00:46:50.543] ├─ mimic-fn@2.1.0
[00:46:50.543] ├─ minimatch@3.1.2
[00:46:50.543] ├─ npm-run-path@4.0.1
[00:46:50.543] ├─ onetime@5.1.2
[00:46:50.543] ├─ path-is-absolute@1.0.1
[00:46:50.543] ├─ path-key@3.1.1
[00:46:50.543] ├─ rc9@1.2.2
[00:46:50.543] ├─ replace-in-file@6.3.5
[00:46:50.544] ├─ require-directory@2.1.1
[00:46:50.544] ├─ resolve-from@5.0.0
[00:46:50.544] ├─ semver@7.3.5
[00:46:50.544] ├─ shebang-command@2.0.0
[00:46:50.544] ├─ shebang-regex@3.0.0
[00:46:50.544] ├─ signal-exit@3.0.7
[00:46:50.544] ├─ string-width@4.2.3
[00:46:50.544] ├─ strip-final-newline@2.0.0
[00:46:50.544] ├─ supports-color@7.2.0
[00:46:50.544] ├─ ufo@0.7.11
[00:46:50.544] ├─ web-vitals@2.1.4
[00:46:50.544] ├─ which@2.0.2
[00:46:50.544] ├─ wrap-ansi@7.0.0
[00:46:50.545] ├─ y18n@5.0.8
[00:46:50.545] ├─ yallist@4.0.0
[00:46:50.545] ├─ yargs-parser@21.1.1
[00:46:50.545] └─ yargs@17.5.1
[00:46:50.545] Done in 2.42s.
[00:46:50.691] [log] Running with @nuxt/vercel-builder version 0.22.1
[00:46:50.692] [log]  ----------------- Prepare build ----------------- 
[00:46:50.692] [log] Downloading files...
[00:46:50.692] [log] Working directory: /vercel/path0
[00:46:50.694] [log] Using yarn
[00:46:50.695] [info] Prepare build took: 3.087219 ms
[00:46:50.695] [log]  ----------------- Install devDependencies ----------------- 
[00:46:50.941] yarn install v1.22.17
[00:46:51.019] [1/5] Resolving packages...
[00:46:51.518] [2/5] Fetching packages...
[00:47:07.872] [3/5] Linking dependencies...
[00:47:07.877] warning " > babel-core@7.0.0-bridge.0" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.878] warning " > babel-jest@27.5.1" has unmet peer dependency "@babel/core@^7.8.0".
[00:47:07.878] warning "babel-jest > babel-preset-jest@27.5.1" has unmet peer dependency "@babel/core@^7.0.0".
[00:47:07.878] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax@1.0.1" has unmet peer dependency "@babel/core@^7.0.0".
[00:47:07.878] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-async-generators@7.8.4" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.878] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-bigint@7.8.3" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.879] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-class-properties@7.12.13" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.879] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-import-meta@7.10.4" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.879] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-json-strings@7.8.3" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.879] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-logical-assignment-operators@7.10.4" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.879] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-nullish-coalescing-operator@7.8.3" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.879] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-numeric-separator@7.10.4" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.880] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-object-rest-spread@7.8.3" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.880] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-optional-catch-binding@7.8.3" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.880] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-optional-chaining@7.8.3" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.880] warning "babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-top-level-await@7.14.5" has unmet peer dependency "@babel/core@^7.0.0-0".
[00:47:07.882] warning " > @nuxtjs/composition-api@0.33.1" has unmet peer dependency "@nuxt/vue-app@^2.15".
[00:47:07.882] warning "nuxt > @nuxt/components@2.2.1" has unmet peer dependency "consola@*".
[00:47:07.885] warning " > vue-chartjs@4.1.1" has incorrect peer dependency "chart.js@^3.7.0".
[00:47:20.526] [4/5] Building fresh packages...
[00:47:21.452] [5/5] Cleaning modules...
[00:47:23.966] Done in 33.03s.
[00:47:23.988] [info] Install devDependencies took: 33293.427006 ms
[00:47:23.989] [log]  ----------------- Nuxt build ----------------- 
[00:47:24.228] [log] Running nuxt build --standalone --no-lock --config-file "nuxt.config.js" /vercel/path0
[00:47:49.061] [fatal] Nuxt build error
[00:47:49.061]   ERROR in ./node_modules_dev/pathe/dist/index.cjs 174:43
[00:47:49.061]   Module parse failed: Unexpected token (174:43)
[00:47:49.061]   You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
[00:47:49.061]   | };
[00:47:49.061]   | const format = function(p) {
[00:47:49.061]   >   const segments = [p.root, p.dir, p.base ?? p.name + p.ext].filter(Boolean);
[00:47:49.062]   |   return normalizeWindowsPath(p.root ? resolve(...segments) : segments.join("/"));
[00:47:49.062]   | };
[00:47:49.062]   @ ./node_modules_dev/@nuxtjs/composition-api/dist/runtime/index.mjs 628:28-44
[00:47:49.062]   @ ./.nuxt/composition-api/plugin.mjs
[00:47:49.062]   @ ./.nuxt/index.js
[00:47:49.063]   @ ./.nuxt/server.js
[00:47:49.063]   @ multi ./node_modules_dev/@nuxt/components/lib/installComponents.js ./.nuxt/server.js
[00:47:49.066] 
[00:47:49.066]    ╭─────────────────────────────╮
[00:47:49.066]    │                             │
[00:47:49.066]    │   ✖ Nuxt Fatal Error        │
[00:47:49.066]    │                             │
[00:47:49.066]    │   Error: Nuxt build error   │
[00:47:49.066]    │                             │
[00:47:49.066]    ╰─────────────────────────────╯
[00:47:49.067] 
[00:47:49.089] Error! Command failed with exit code 1: npx nuxt build --standalone --no-lock --config-file "nuxt.config.js" /vercel/path0

> Blockquote

it looks like it is an error related to modules but i have no idea of how i should fix it does anyone already faced this issues

1 Answers

Since you didn't specified anything for the target key, it is using the default aka 'server'.

Since Vercel does not provide a full time running Node.js regular server, you'll need to host your app on Heroku, Render, DigitalOcean or alike.

Related