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

233
Visualizações
Why does the import of a package (mongoose) lead to a ReferenceError in ReactJS?

When trying to run the following code in ReactJS, I get the following error: Uncaught ReferenceError: process is not defined. If I remove the const mongoose = require('mongoose'); line, everything works well. It's worth noting that I have installed mongoose using the npm i mongoose command (version 6.3.1).

import logo from "./logo.svg";
import React, { Component } from 'react';
import "./App.css";
const mongoose = require('mongoose');

export default class Test extends React.Component {

        render() {
                return (
                        <div>
                                <p>Hey StackOverflow!</p>
                        </div>
                );
        }
}

What is the cause of this problem? Is it a problem with the mongoose package specifically?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Why do you need mongoose in your frontend code in the first place? To answer your question specifically: mongoose is using the global process variable which is only available in a NodeJS context (e.g. a backend server application), not Browser context.

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