Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

220
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!