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

244
Visualizações
Problem with Node.JS and jsconfig.json with absolute imports

IDE: Replit

Good afternoon, thanks for checking out.

I wanted to implement absolute imports to my node project, but something odd is happening whenever I try to run the code.

Here are the things I set for my jsconfig.json file:

{
  "compilerOptions": {
    "baseUrl": "src"
  }
}

Now, this is how i'm calling the file I need inside another one:

const {title} = require('util.js')

Oddly, replit's intellisense shows up the right path: Thumbs Up From Replit

But then, when I finally execute the code, I get this error message:

Error: Cannot find module '/home/runner/Moniqueta-Discordjs/node_modules/util.js/index.js'. Please verify that the package.json has a valid "main" entry at tryPackage (node:internal/modules/cjs/loader:353:19) at Function.Module._findPath (node:internal/modules/cjs/loader:566:18) at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object. (/home/runner/Moniqueta-Discordjs/src/commands/rps.js:2:17) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) { code: 'MODULE_NOT_FOUND', path: '/home/runner/Moniqueta-Discordjs/node_modules/util.js/package.json', requestPath: 'util.js' }

I tried following the error by adding a "valid main entry to my package.json" file, like this:

{
  "name": "moniqueta-discordjs",
  "version": "1.0.0",
  "description": "",
  "main": "src/index.js",
  "keywords": [],
  "author": "sum117",
  "license": "ISC",
  "dependencies": {
    "@replit/database": "^2.0.2",
    "discord.js": "^13.8.0",
    "src": "^1.1.2",
    "util.js": "^0.0.0"
  }
}

And when I checked it, it had "util.js" as a declared dependency, I really don't understand what's going on.

Thanks for reading. What am I missing? I really would love this to work...

If my explanation is not enough, you can access my open source code via the link.

about 4 years ago · Juan Pablo Isaza
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