DEV Community

loading...

MERNG PROJECT... I NEED HELP!! IM SICK OF THE ERRORS!!!!

yobretyo profile image Bret ・1 min read

I’m getting “module not found” for Apollo-server, also for gql and then I’m getting “some”, is undefined?????
I started out with the wrong way of learning MERNG, it was all backend server side.... nothing at the client, but it did work a little.... BUT, I want to do it the right way.
There’s all these random “depreciated, update” trash, WHY CANT THEY JUST MAKE IT WORK!!!!

I’m getting undefined when it’s imported,
Then there’s “import” or there’s “const Items
= require(‘something’);

I’m trying to make a simple MERNG app, and it’s turning to trash!!!

I’ve done it before, but the wrong way of everything on the server.

Discussion (5)

pic
Editor guide
Collapse
nhidtran profile image
nhidtran • Edited

Hello! I would take one piece at a time
Set up your react app first and make sure you can get it to start. That your babel is set up to handle import statements etc. The error is less about the stack you choose, import not being native. Just get something to render first!

don't get discouraged and take everything step by step! It's a tech stack, but built it one one stack piece at a time. You can do it!

Collapse
gamezcua1 profile image
Gerald Amezcua

I would really recommend you to go ahead and read about what Babel is. JavaScript, more specifically EcmaScript has now a days way many different versions and ways to do the same kind of stuff, if you use EcmaScript 2016 you'll make use of "import something from 'package'" but instead if you use EcmaScript 8 you'd have to use "const something = require ('package')"

I would really recommend you to take a look at that so that you can better understand what they mean and how to work with them and compile them into the one you most likely need.

Collapse
stereobooster profile image
stereobooster
  • ES6 = EcmaScript 2015 (yeah it's confusing). This is where ES modules first apeared
  • require ('package') never was in EcmaScript standard. It is node.js thing, which also supported by Babel, Webpack etc
Collapse
valeriavg profile image
Valeria • Edited

I have two suggestions, one of them is a bit controversial.

First one.
Try to do it one thing at a time. Start with http server that returns something. For example, install Apollo server in a new project and make a query that returns a string. Once this is out of the way, create a query that returns something from MongoDB. Bit of advice: don't use mongoose and go with a native driver instead. Once you've figured that part, create a React app and try rendering something. And at last, once this is working, try connecting React app with your server.

Second, controversial approach.

Try doing the same thing but with the minimum amount of packages. Limit it to e.g. React, graphql and mongo driver. Write the rest yourself. While it's the longest road, this will give you an idea on what actually is going on in your code.

Good luck!

Collapse
ducaale profile image
Mohamed Dahir

I've found this article helpful when I was learning about writing a GraphQL server. The article is a part of a comprehensive series on everything GraphQL related including how to setup a nodejs project.