basir / mern-amazona

Build Ecommerce Like Amazon By MERN Stack
https://www.youtube.com/watch?v=ZjwBs3n7waY&list=PLeh2GWv22bmSQ9oBSYTd469_AQjPGpzyv
324 stars 243 forks source link

Lesson 33 Heroku deployment, database connection #7

Open L00ka5z78 opened 1 year ago

L00ka5z78 commented 1 year ago

Hello everybody! Im not sure that it is an issue or it just me doing something wrong. Im following instructions, but there is a problem im facing. After editing and copying .env file to root directory I run the npm start , the server is running and database is connected. Until now it seems to works well. But after clicking the link sending to localhost:5000 it displays network error in the browser and this error in the terminal and the app is crashed.

    callback(new error_1.MongoServerError(document));
    MongoServerError: user is not allowed to do action [find] on [mern-amazona-db.products]

Does anyone faced similar issue. Im trying to figure it out on my own to get unstuck, but im running out of ideas. And in console there is : Failed to load resource: net::ERR_CONNECTION_REFUSED

L00ka5z78 commented 1 year ago

Problem i described above I fixed, by myself. Now getting in another problem.
My build on Heroku is failed. I think I followed exactly everything, but it throws this message:

-----> Building on the Heroku-22 stack -----> Determining which buildpack to use for this app -----> Node.js app detected

-----> Creating runtime environment

   NPM_CONFIG_LOGLEVEL=error
   NODE_VERBOSE=false
   NODE_ENV=production
   NODE_MODULES_CACHE=true

-----> Installing binaries engines.node (package.json): 18.x engines.npm (package.json): unspecified (use default)

   Resolving node version 18.x...
   Downloading and installing node 18.11.0...
   Using default npm version: 8.19.2

-----> Installing dependencies Installing node modules (package.json)

   up to date, audited 1 package in 122ms

   found 0 vulnerabilities

-----> Build Running build

   > amazona@1.0.0 build
   > cd backend && npm install && cd ../frontend && npm install &&npm run build

   added 102 packages, and audited 103 packages in 2s

   11 packages are looking for funding
     run `npm fund` for details

   found 0 vulnerabilities

npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: use-reducer-logger@1.0.2 npm ERR! Found: react@18.2.0 npm ERR! node_modules/react npm ERR! react@"^18.2.0" from the root project npm ERR! peer react@">=16.3.0" from @paypal/react-paypal-js@7.8.1 npm ERR! node_modules/@paypal/react-paypal-js npm ERR! @paypal/react-paypal-js@"^7.8.1" from the root project npm ERR! 15 more (@react-aria/ssr, @restart/hooks, @restart/ui, ...) npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer react@"^16.8" from use-reducer-logger@1.0.2 npm ERR! node_modules/use-reducer-logger npm ERR! use-reducer-logger@"^1.0.2" from the root project npm ERR! npm ERR! Conflicting peer dependency: react@16.14.0 npm ERR! node_modules/react npm ERR! peer react@"^16.8" from use-reducer-logger@1.0.2 npm ERR! node_modules/use-reducer-logger npm ERR! use-reducer-logger@"^1.0.2" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! See /tmp/npmcache.HrN0Q/eresolve-report.txt for a full report. npm ERR! A complete log of this run can be found in: npm ERR! /tmp/npmcache.HrN0Q/_logs/2022-10-25T15_38_15_427Z-debug-0.log -----> Build failed

   We're sorry this build is failing! You can troubleshoot common issues here:
   https://devcenter.heroku.com/articles/troubleshooting-node-deploys

   If you're stuck, please submit a ticket so we can help:
   https://help.heroku.com/

   Love,
   Heroku

! Push rejected, failed to compile Node.js app. ! Push failed

Anyone has idea how can I fix it? Would be nice to get some help.

mselmank commented 1 year ago

@L00ka5z78 the script would be

cd backend && npm install && cd .. && cd frontend && npm install &&npm run build thats works for me instead of this cd backend && npm install && cd ../frontend && npm install &&npm run build

L00ka5z78 commented 1 year ago

Thanks. Now Im facing with lessons 35. Create search screen. it is created, after launching databse is conneted so is th backend/frontend. homepage displays all properly, but after clicking search products button it doesnt load them. It shows just a spinning spinner. No, errors in console, no errors in terminals. Do you know what might be a reason?

2022-10-26 (1)