Alheimsins / bigfive-web

Website for taking personality tests
MIT License
213 stars 86 forks source link

Can't run this application #149

Closed jfrcom closed 5 years ago

jfrcom commented 5 years ago

Hello,

I tried to deploy this application to Heroku/Now. Unfortunately, I get some errors, when I try to deploy. A few months ago it still worked. Now it doesn't even work on my local machine. In cmd, I type npm install than npm run dev. It says Server compiled successfully but I can't open on localhost:3000. I would appreciate your help.

Thank you!

zrrrzzt commented 5 years ago

Hi 👋 Thank you for your interest in our little project.

Since a couple of months ago Now have released a new version of their platform. It is as far as I know not possible to deploy via a github url anymore. I've updated the README to describe the new way to do Now deployments. We hope to be able to support Now v2 as well, but don't hold your breath. For now just try the updated description.

As for your problems on your local machine. Make sure you have Node version >= 10 and do a fresh clone and npm install.

jfrcom commented 5 years ago

Thank you for your quick answer! `UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, open '/home/nowuser/src/node_modules/next-offline/register-sw-compiled.js'

[0] (node:88) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. [0] (node:88) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)`

When I try to deploy to Now I get this errors. When I try to run it on my local machine it just `npm run dev

alheimsins-b5-web@1.0.2 dev C:\Users\vfjon\OneDrive\Desktop\bigfive-standard node server.js`

shows that and stops doing anything.

zrrrzzt commented 5 years ago

Regarding the problems at your local machine: have you tried to run it outside of OneDrive? Just guessing here since I just ran a fresh install myself and it worked.

When it comes to Now: Have you changed the variables in production.env to match your environment? I deploy to bru1 which server does your deploy go to? It will tell you at the end of the deploy message. Something like ✔ Scaled 1 instance in bru1

And as a final solution: Have you tried the docker version of running your own server?

jfrcom commented 5 years ago

Everything is working fine right now. Thanks a lot for your patience and help! Edit: When I deployed this application at now, and I have answered all the questions the last button is not working (The See Results button). On my local machine, this button is working perfectly!

zrrrzzt commented 5 years ago

@maccyber any ideas?

@bluecomjona do you see the result in your MongoDB for the Now deployed version?

jfrcom commented 5 years ago

No, nothing happens. No result in my MongoDB. Have you tried it out with now? And have you got the same issue? And how did you deploy your site bigfive-test.com?

maccyber commented 5 years ago

@bluecomjona bigfive-test.com is deployed to now. Try to open developer console in the browser and look for error messages after you've clicked "See results" button.

Verify that your settings in production.env is correct. DB_CONNECTION should be i.e. hacktoberfest:hacktoberfest1@ds153659.mlab.com:53659/bigfive

URL should be the URL you alias to. In my case https://bigfive-test.com

Also remember to change the alias url inside now.json

jfrcom commented 5 years ago

Before I click the button I've got this error: Failed to load resource: the server responded with a status of 404 () main-ac9ee7adde660ee2e4c0.js:1 SW registered: ServiceWorkerRegistration' When I clicked the button I get those errors:locales/de/common.json:1 Failed to load resource: the server responded with a status of 404 () main-ac9ee7adde660ee2e4c0.js:1 SW registered: ServiceWorkerRegistration 2test.js:8 OPTIONS https://ancient-spire-72163.herokuapp.com/api/save 503 (Service Unavailable) (anonymous) @ test.js:8 e.exports @ test.js:8 e.exports @ test.js:8 Promise.then (async) f.request @ test.js:8 f.(anonymous function) @ test.js:8 (anonymous) @ test.js:8 (anonymous) @ test.js:8 w @ commons.2c54b9caec4ce4a1c218.js:6 (anonymous) @ commons.2c54b9caec4ce4a1c218.js:6 e.(anonymous function) @ commons.2c54b9caec4ce4a1c218.js:6 j @ test.js:8 n @ test.js:8 (anonymous) @ test.js:8 (anonymous) @ test.js:8 T.value @ test.js:8 (anonymous) @ commons.2c54b9caec4ce4a1c218.js:22 p @ commons.2c54b9caec4ce4a1c218.js:22 (anonymous) @ commons.2c54b9caec4ce4a1c218.js:22 _ @ commons.2c54b9caec4ce4a1c218.js:22 j @ commons.2c54b9caec4ce4a1c218.js:22 E @ commons.2c54b9caec4ce4a1c218.js:22 N @ commons.2c54b9caec4ce4a1c218.js:22 Sn @ commons.2c54b9caec4ce4a1c218.js:22 Fa @ commons.2c54b9caec4ce4a1c218.js:22 Ae @ commons.2c54b9caec4ce4a1c218.js:22 jn @ commons.2c54b9caec4ce4a1c218.js:22 Ma @ commons.2c54b9caec4ce4a1c218.js:22 Cn @ commons.2c54b9caec4ce4a1c218.js:22 test:1 Access to XMLHttpRequest at 'https://ancient-spire-72163.herokuapp.com/api/save' from origin 'https://bigfive-web-rkexxnwqdh.now.sh' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. test.js:8 Uncaught (in promise) Error: Network Error at e.exports (test.js:8) at XMLHttpRequest.r.onerror (test.js:8)`

Thanks

maccyber commented 5 years ago

URL in production.env should be set to a static URL.

zrrrzzt commented 5 years ago

You must enable cors for the api as well

jfrcom commented 5 years ago

Almost everything is working fine right now. Unfortunately, nothing gets to the database when I completed the test. Could you say me what should be in the config.js? This is my config.js. Of course, I inserted my real password. At URL: process.env.URL || I inserted where it is running at the moment. Same URL like in the production.env. config.js: module.exports = { JWT_SECRET: process.env.JWT_SECRET || 'Gibberish, jibberish, jibber-jabber and gobbledygook', DB_CONNECTION: process.env.DB_CONNECTION || 'mongodb://jona:password@ds052978.mlab.com:52978/bigfive', DB_COLLECTION: process.env.DB_COLLECTION || 'results', URL: process.env.URL || 'https://personalitytest.now.sh/' }

I still have two questions. At the moment I am translating the choices and questions in German. Could you say me how to give them to you when I'm ready? How can I make (or you) a variable for the timer (like the data._id) so I can work with the time? Thanks a lot for your great help!

PS: @zrrrzzt I don't know how to enable the cors for the API.

zrrrzzt commented 5 years ago

Hello again @bluecomjona :-)

Been a busy week so I have not been able to get back to you until now.

I think there is a german translation of the available already. This is the base module for the questions and there is a long list of supported languages https://github.com/Alheimsins/b5-johnson-120-ipip-neo-pi-r

You said everything worked a couple of months ago... have you done a fresh clone of the repo? Some of your problems does not make sense so is there a possibility that you are using the old version of this?

Would you try to do a completely fresh install of everything? New folder and so on?

Btw if you just want to able able to take the tests and share them or save files and do not need a database there is a minimal static version of the test available: https://github.com/zrrrzzt/b5-web

jfrcom commented 5 years ago

Hello again,

There is a "German" translation, but almost no question is translated and if it is translated it's completely false. I would like to make a new one. The connection to my database is still not working. I made a new clone and so on but it doesn't work.. In the console from the chrome developer tools I get this error: Failed to load resource: the server responded with a status of 404 () I deployed my site with now (V1). After deploying I made an alias with my custom address and this address is inside of the production.env, now.json and in the config.js (URL: process.env.URL || 'https://custom-url.de/'). Could you say me what has to be inside of the config.js? And is it possible to create a variable for the end time, after pressing the submit button (like data._id)?

Thank's a lot for your help!

zrrrzzt commented 5 years ago

ah, see what you mean regarding the translation. Just follow the instructions for translations at https://github.com/Alheimsins/b5-johnson-120-ipip-neo-pi-r and submit your PR when you're finished.

I'll try to do a completely new deploy tomorrow and make sure I document every step in the README. Hopefully there's just something we're not explaining quite right.

zrrrzzt commented 5 years ago

@bluecomjona Here is the new guide for deploying to Now: https://github.com/Alheimsins/bigfive-web/blob/master/docs/now.md

It was written while I did a completely new now deploy from scratch. It's running at https://myb5test.now.sh and saves to the database.

Regarding your request for saving the end time: Add a separate issue as a feature request and we'll look into it. Or create it and do a PR :-)