Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
Cannot read property 'startsWith' of undefined require('path') resolve

I am trying to add my local custom Nuxt module to my Nuxt application and I keep getting the error:

Cannot read property 'startsWith' of undefined                                                                                                

  at Resolver.g [as _require] (node_modules\jiti\dist\jiti.js:1:54052)
  at Resolver.requireModule (node_modules\@nuxt\core\dist\core.js:381:29)
  at ModuleContainer.addModule (node_modules\@nuxt\core\dist\core.js:182:38)
  at node_modules\@nuxt\utils\dist\utils.js:639:43
  at async ModuleContainer.ready (node_modules\@nuxt\core\dist\core.js:55:5)
  at async Nuxt._init (node_modules\@nuxt\core\dist\core.js:478:5)

I require 'path' as below in module.js of my Nuxt module:

const { resolve, join } = require('path')
const { readdirSync } = require('fs')

It displays a list of files that has startsWith(). For instance:

node_modules@nuxt\utils\dist\utils.js:

const startsWithAlias = aliasArray => str => aliasArray.some(c => str.startsWith(c));
...
const isWindows = process.platform.startsWith('win');
...
if (r.path && r.path.startsWith('/')) {
      routes.push(r.path);
    } else if (route !== '/' && route[route.length - 1] === '/') {
      routes.push(route.slice(0, -1));
    } else {
      routes.push(route);
    }
...
const sanitizedKey = key.startsWith('_') ? key.substr(1) : key;
...
if (key.startsWith('_') && key.length > 1) {
          route.path += '?';
        }
...
if (
    dir1 &&
    dir2 &&
    (
      dir1 === dir2 ||
      (
        dir1.startsWith(dir2) &&
        !path__default['default'].basename(dir1).startsWith(path__default['default'].basename(dir2))
      )
    )
  ) {
 ...
 if (key.startsWith('_')) {
    return `:${key.substr(1)}`
  }
 

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Looks like it might be trying to initialise the module on the client so it's not recognising node specific code.

If by chance you're using the nuxt-vite package for nuxt 2, this could potentially be why as I don't think vite-plugin-vue2 which it uses works with SSR yet.

* I understand that may be a weird mix of vague and specific, but going off the question it looks very similar to an issue my teammate had when looking into nuxt-vite. Also, judging by the stack trace it's failing before it even properly gets in to the module.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda