Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda