klequis / private-money-client

5 stars 2 forks source link

Local development setup #16

Closed klequis closed 3 years ago

klequis commented 3 years ago

Use this post to establish local dev setup for app.

klequis commented 3 years ago

@dhaef

I created data for you to use and have documented setting-up the database and server. You can find the instructions in the project wiki

The pages for server setup are numbered 1 - 5.

I'll try to do client setup later or tomorrow.

Let me know how it goes.

dhaef commented 3 years ago

@klequis The setup is going smoothly but I'm not seeing "mm.aabank.checking.2222.csv" in /setup-resources

klequis commented 3 years ago

@dheaf It is there now.

I had .csv in .gitignore to avoid uploading actual data.

I'll have to do client setup tomorrow. Don't really remember what is needed. Could be nothing.

klequis commented 3 years ago

@dheaf Nothing needs to be done on the client to get it to run. I added a setup step for it anyway just to get you started. There is no user guide. Feel free to ask as many questions as you need.

dhaef commented 3 years ago

@klequis Thank you!

Now when I start the server I get the error below. I created config.settings.js in /server/config. Any ideas?

Error: Cannot find module './config.settings' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.<anonymous> (/Users/derekheafner/Documents/openSourceContributions/private-money-server/config/index.js:3:1) at Module._compile (internal/modules/cjs/loader.js:778:30) at Module._compile (/Users/derekheafner/Documents/openSourceContributions/private-money-server/node_modules/pirates/lib/index.js:99:24) at Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Object.newLoader [as .js] (/Users/derekheafner/Documents/openSourceContributions/private-money-server/node_modules/pirates/lib/index.js:104:7) at Module.load (internal/modules/cjs/loader.js:653:32)

klequis commented 3 years ago

Looks like you are using Windows and that is likely the problem. There is an easy fix for it I used a few years ago but have forgotten. I'll look for it.

You can also look into it. The problem is in the 'scripts' section of package.json

"start-dev": "DEBUG=server* NODE_ENV=development NODE_PATH=./ nodemon --exec babel-node server/index.js"

If I remember correctly, it is the NODE_PATH=./ that Windows doesn't understand and NODE_ENV=development might be a problem as well.

klequis commented 3 years ago

In the mean time, we should also consider if it is a machine configuration problem. Here is how I setup my machine. Please take a look to see if something seems significant, different or missing.

https://klequis.io/full-stack-mern-development-series/

dhaef commented 3 years ago

I'm actually running on a mac

klequis commented 3 years ago

Oh, I though mac had /home not /Users, but good. Should be easier to figure out.

klequis commented 3 years ago

I did a setup on a Mac and had no problem. The issue I was thinking of was with Windows.

Can you show me a screen shot of you editor similar to this one?

config settings

dhaef commented 3 years ago

I figured it out. I had mistaken "/server/config/config.settings.js" as "/server/server/config/config.settings.js"

I now got a 0 at the end of my import request "{"dataLoaded":"[{\"operation\":\"load data\",\"status\":\"success\",\"numDocsLoaded\":0}]"}" and my password in config.settings.js is correct as I forgot to change it when creating

Screen Shot 2020-12-16 at 5 16 52 PM
klequis commented 3 years ago

It isn't likely a password issue bec that would cause the server to throw an error. But just to double-check, according to your picture above your password is literately 'yourPWD' which is OK as long as that is what you used for you mongodb users.

Did you look at the terminal for server to see if there are any errors?

You should see something like (your numbers will be different) import-output

Looking at the accounts collection in MongoDB Compass it should look like this: (ignore that my db name is pm-setup, that's a tmp thing I did)

accounts-in-compass

dhaef commented 3 years ago

Yeah that is what I used for the mongodb password.

I don't have any errors in the server terminal I just get this.

Screen Shot 2020-12-16 at 7 24 03 PM

My accounts collections looks correct as well

Screen Shot 2020-12-16 at 7 25 10 PM
klequis commented 3 years ago

I created a new branch named 'debug-import'. Please check it out and then re-execute the import from the browser. Post a picture of all the output in the terminal.

dhaef commented 3 years ago
Screen Shot 2020-12-16 at 8 14 36 PM
klequis commented 3 years ago

So '01: accounts' is the result of a db call. It should be an array but looks undefined from the output. I put some more debug (console.log) code in around the db call to see what is happening. Please pull the new code, give it a try and post a screen shot.

dhaef commented 3 years ago

Looks like my testUser is undefined

Screen Shot 2020-12-16 at 11 46 53 PM
klequis commented 3 years ago

testUser is undefined for me as well. Currently you are using devUser.

The first 'find' is the query to get the accounts. 'ret' is the return value of the query and it is an empty array. That is a key clue that points to something being off in the db.

  1. Show me a view of Compass like this

remember wherever you see 'pm-setup' it must be 'private-money' on yours.

compass

  1. Then in the console follow this procedure and let me know the results
    
    // log into mongo as devUser
    mongo -u devUser -p --authenticationDatabase private-money
    // enter password at prompt

// switch to the private-money db use private-money

db.accounts.find({}) // should print out contents 'accounts'

db.accounts.find({ active: { '$ne': false } }) // result should be same result as previous command

dhaef commented 3 years ago
Screen Shot 2020-12-17 at 3 28 14 PM

When I follow the steps for step 2 I get no output

klequis commented 3 years ago

I think, guessing from your screenshot, the problem is you are connected to mongodb atlas in the cloud. The app and the queries in the console are looking at mongodb running on your local machine.

I created some instructions for using localhost. Sorry, I don't know your experience level so apologies if you don't need the instructions:

https://github.com/klequis/private-money-client/wiki/3.-Setup:-Setup-the-private-money-Database

dhaef commented 3 years ago

That did it! I had always used atlas prior when using mongodb so that was my confusion.

Really appreciate all the help

klequis commented 3 years ago

Great. Were you able to get the client running? I don't remember writing instructions but just clone it, npm install, npm start and it should work

dhaef commented 3 years ago

Yeah the client is up and running