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

filename.split error on nuxt generate and ssr #583

Open
jvrsolis opened this issue Jul 22, 2022 · 2 comments
Open

filename.split error on nuxt generate and ssr #583

jvrsolis opened this issue Jul 22, 2022 · 2 comments

Comments

@jvrsolis
Copy link

jvrsolis commented Jul 22, 2022

 ERROR  filename.split is not a function                                           08:19:59

  at normalizePath (node_modules/vite/dist/node/chunks/dep-c9998dc6.js:2418:23)
  at getMatcherString$1 (node_modules/vite/dist/node/chunks/dep-c9998dc6.js:2427:16)
  at Object.test (node_modules/vite/dist/node/chunks/dep-c9998dc6.js:2446:33)
  at result (node_modules/vite/dist/node/chunks/dep-c9998dc6.js:2462:25)
  at Array.filter (<anonymous>)
  at resolveSSRExternal (node_modules/vite/dist/node/chunks/dep-c9998dc6.js:41141:31)
  at doBuild (node_modules/vite/dist/node/chunks/dep-c9998dc6.js:41603:36)
  at async Module.build (node_modules/vite/dist/node/chunks/dep-c9998dc6.js:41557:16)
  at async buildServer (node_modules/@nuxt/vite-builder/dist/index.mjs:646:5)
  at async bundle (node_modules/@nuxt/vite-builder/dist/index.mjs:899:3)

The error seems to come from vite trying split a filename that is actually a function. Specifically
The transpile defu function from this code line from the nuxt axios module. I was able to figure this out by doing a try catch and logging the the function.

node_modules/@nuxtjs/axios/lib/module.js:42

  // Transpile defu (IE11)
  if (nuxt.options.build.transpile /* nuxt 1 */) {
    nuxt.options.build.transpile.push(({ isClient }) => isClient && 'defu')
  }

Here is the code that throws the errors don't mind the console log or try catch the issue was in filename.split which was the only code before my manual updates

const normalizePath$5 = function normalizePath(filename) {
    try {
      return filename.split(path$r.win32.sep).join(path$r.posix.sep);
    } catch (error) {
      console.log(filename());
      throw error;
    }
};

The following list is the result is a console.log dump of the files the above code tries to "normalize"

/Users/javi/Code/app.facsware/node_modules/@fortawesome/fontawesome-svg-core/index.es.js
/Users/javi/Code/app.facsware/node_modules/@fortawesome/fontawesome-svg-core       08:39:38
./index.js                                                                         08:39:38
/Users/javi/Code/app.facsware/node_modules/@fortawesome/fontawesome-svg-core       08:39:38
./index.es.js                                                                      08:39:38
/Users/javi/Code/app.facsware/node_modules/@ionic/vue/dist/index.esm.js            08:39:38
/Users/javi/Code/app.facsware/node_modules/@ionic/vue                              08:39:38
css/*.css                                                                          08:39:38
/Users/javi/Code/app.facsware/node_modules/@sentry/tracing/esm/index.js            08:39:38
/Users/javi/Code/app.facsware/node_modules/@sentry/tracing                         08:39:38
./cjs/index.js                                                                     08:39:38
/Users/javi/Code/app.facsware/node_modules/@sentry/tracing                         08:39:38
./esm/index.js                                                                     08:39:38
#internal/nitro                                                                    08:39:38
@ionic/vue                                                                         08:39:38
@headlessui/vue                                                                    08:39:38
@fortawesome/vue-fontawesome                                                       08:39:38
@fortawesome/fontawesome-svg-core                                                  08:39:38
@fortawesome/free-regular-svg-icons                                                08:39:38
@fortawesome/free-solid-svg-icons                                                  08:39:38
@fortawesome/free-brands-svg-icons                                                 08:39:38
@nuxt/ui-templates                                                                 08:39:38
@formkit/nuxt/dist/runtime                                                         08:39:38
@formkit/vue                                                                       08:39:38
@intlify/shared                                                                    08:39:38
@intlify/core-base                                                                 08:39:38
@vue/devtools-api                                                                  08:39:38
@intlify/devtools-if                                                               08:39:38
vue-i18n                                                                           08:39:38
[Function (anonymous)]     

As you can see the function pushed by the transpile defu from the axios module section is where its breaking down. I can also verify that from the try catch and logging the result of the function which is throws an error that points to that line of code in the axios module.

I am unsure how to fix this issue

Here are is the output from nuxi
Nuxt project info: 08:44:53


  • Operating System: Darwin
  • Node Version: v17.9.0
  • Nuxt Version: 3.0.0-rc.6
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Currently running nuxt ^3.0.0-rc.6, vue ^3.2.37, @nuxtjs/axios ^5.13.6, vite 2.9.14

It all really gets initiated by
resolveSSRExternal (node_modules/vite/dist/node/chunks/dep-c9998dc6.js:41142:31)

let externals = [...ssrExternals];
    if (ssrConfig === null || ssrConfig === void 0 ? void 0 : ssrConfig.noExternal) {
        externals = externals.filter(createFilter$1(undefined, ssrConfig.noExternal, { resolve: false }));
    }
    return externals;

if i console log ssrExternals and ssrConfig i get:

[                                                                                  08:57:47
  '#internal/nitro',
  'vue',
  '@vue/server-renderer',
  '@capacitor-community/app-icon',
  '@capacitor/android',
  '@capacitor/ios',
  '@intlify/vue-router-bridge',
  '@nuxt/content',
  '@nuxt/postcss8',
  '@nuxt/types',
  '@nuxtjs/dotenv',
  '@nuxtjs/pwa',
  '@nuxtjs/tailwindcss',
  '@tailwindcss/forms',
  '@types/node',
  'nuxt',
  'postcss-import',
  'sass',
  'tailwindcss',
  '@capacitor-community/electron',
  '@capacitor/app',
  '@capacitor/cli',
  '@capacitor/core',
  '@capacitor/device',
  '@capacitor/haptics',
  '@capacitor/keyboard',
  '@capacitor/network',
  '@capacitor/status-bar',
  '@capacitor/storage',
  '@capacitor/toast',
  '@formkit/i18n',
  '@formkit/nuxt',
  '@formkit/themes',
  '@fortawesome/fontawesome-svg-core',
  '@fortawesome/free-brands-svg-icons',
  '@fortawesome/free-regular-svg-icons',
  '@fortawesome/free-solid-svg-icons',
  '@fortawesome/vue-fontawesome',
  '@headlessui/vue',
  '@heroicons/vue',
  '@intlify/nuxt3',
  '@ionic/core',
  '@ionic/pwa-elements',
  '@ionic/vue',
  '@kevinmarrec/nuxt-pwa',
  '@nuxtjs/axios',
  '@pinia/nuxt',
  '@sentry/tracing',
  '@sentry/vue',
  '@tailwindcss/aspect-ratio',
  '@tailwindcss/line-clamp',
  '@tailwindcss/typography',
  '@vueuse/core',
  'axios',
  'lodash',
  'notiwind',
  'pinia',
  'vue-i18n',
  'html-tags',
  'ufo',
  '@formkit/vue',
  'defu',
  'vue-router',
  '@sentry/browser',
  'unctx'
] {
  external: [
    '#internal/nitro',
    'vue',
    '@vue/server-renderer'
  ],
  noExternal: [
    '@ionic/vue',
    '@headlessui/vue',
    '@fortawesome/vue-fontawesome',
    '@fortawesome/fontawesome-svg-core',
    '@fortawesome/free-regular-svg-icons',
    '@fortawesome/free-solid-svg-icons',
    '@fortawesome/free-brands-svg-icons',
    '@nuxt/ui-templates',
    '@formkit/nuxt/dist/runtime',
    '@formkit/vue',
    '@intlify/shared',
    '@intlify/core-base',
    '@vue/devtools-api',
    '@intlify/devtools-if',
    'vue-i18n',
    [Function (anonymous)],
    '@pinia/nuxt/dist/runtime',
    '@vueuse/head',
    '@nuxtjs/dotenv',
    '@nuxtjs/tailwindcss',
    '@formkit/nuxt',
    '@intlify/nuxt3',
    '@nuxt/content',
    '@nuxtjs/axios',
    '@pinia/nuxt',
    '@nuxt/telemetry',
    '/Users/javi/Code/app.facsware/node_modules/@nuxt/content/dist/runtime/components',
    /\/esm\/.*\.js$/,
    /\.(es|esm|esm-browser|esm-bundler).js$/,
    '/__vue-jsx',
    '#app',
    /(nuxt|nuxt3)\/(dist|src|app)/,
    /@nuxt\/nitro\/(dist|src)/
  ]
}

As you can see the anonymous function from earlier is listed, do i have something wrong about my config? Maybe thats the issue?

I have this in the modules dir
modules: [
'@nuxtjs/dotenv',
'@nuxtjs/tailwindcss',
'@formkit/nuxt',
'@intlify/nuxt3',
'@nuxt/content',
['@nuxtjs/axios', {proxyHeaders:false}],
'@pinia/nuxt'
],

Seems if i just change the function to a string defu like in some suggestions ive seen it works.
The alternative is using nuxtjs-alt/axios for now

@jvrsolis jvrsolis changed the title filename.split error on nuxt generate and ssr and filename.split error on nuxt generate and ssr Jul 22, 2022
@ghost
Copy link

ghost commented Sep 5, 2022

Facing the same issue...

@WpSlt
Copy link

WpSlt commented Oct 2, 2022

me too...

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

2 participants