Running node.js and dependencies

@prabalsingh24
Ya that’s a common sense as we are using Google-fonts
Also elastisearch will show warnings in console that connection is not live, so anyone can get idea about that error easily…

@Prabhleen
I hope you were able to find the connection issue, on your own if is it was there.
But I think you really missed the git Submodule concept we are using. So go through the above idea once…
Also you will come to learn about git Submodule.

And yes! Please share with us, what was the actuall issue!!.. 1.internet connection or 2.git Submodule

1 Like

@endurance21 thanks a lot for your help. I thought this might be the thing to get css working but no, sadly not. :slightly_frowning_face:. The Output has not changed the tiniest bit.

Following is the error i get, when i try to connect to localhost

[Mon Feb 24 2020 21:18:54 GMT+0530 (India Standard Time)] ERROR Error: getaddrinfo ENOTFOUND postgres
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:64:26) {
GET /js/bundle.js 404 34.511 ms - -
GET /js/error.js 404 32.960 ms - -
GET /manifest.json 304 49.361 ms - -
GET /images/icons/favicon-32x32.png 200 81.766 ms - 627
(node:19780) UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND postgres
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:64:26)
(node:19780) 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(). To terminate the node process on
unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see Command-line API | Node.js v21.5.0 Documentation). (rejection id: 14)
GET /statistics - - ms - -
[Mon Feb 24 2020 21:18:54 GMT+0530 (India Standard Time)] ERROR Error: getaddrinfo ENOTFOUND postgres
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:64:26) {
errno: ‘ENOTFOUND’,
code: ‘ENOTFOUND’,
syscall: ‘getaddrinfo’,
hostname: ‘postgres’
}
GET / 500 2395.447 ms - -
GET /stylesheets/style.css 404 199.260 ms - -
GET /stylesheets/react-virtualized.css 404 62.804 ms - -
GET /stylesheets/react-virtualized-select.css 404 62.414 ms - -
GET /images/BookBrainz_logo_mini.svg 304 373.393 ms - -
GET /images/BrowserStack.png 304 384.085 ms - -
GET /stylesheets/react-datepicker.css 404 78.345 ms - -
GET /js/bundle.js 404 433.917 ms - -
GET /js/error.js 404 420.602 ms - -
GET /manifest.json 304 2.214 ms - -
GET /stylesheets/react-virtualized.css 404 57.602 ms - -
GET /stylesheets/style.css 404 86.316 ms - -
GET /stylesheets/react-virtualized-select.css 404 101.109 ms - -
GET /stylesheets/react-datepicker.css 404 112.359 ms - -

@Prabhleen
Have you tried two steps?.
1.git Submodule init
2.git Submodule update
?..

yess and also checked the internet connection.

1 Like

@Prabhleen
Let me ask couple of questions…

  1. Have you installed all dependencies?.
    Including elastisearch, postgresql, redis
  2. Have you edited the cover config file, changed the clientid and client secret key ?.
    3.have you replaced “elasticsearch:9200” to “localhost:9200” on line 31 of config file…

It looks like currently you are using config/config.json file, which tries to connect to the services using the docker container names (elasticsearch, portgres and redis) instead of localhost or 127.0.0.1 for your local machine.
If you’re not planning on using docker at all, you can modify your config/config.json file (instead of using config.local.json, and then just run npm start without specifying a configuration file) to look like this:

{
	"site": {
		"proxyTrust": true,
		"log": "debug",
		"forceExitAfterMs": 5000
	},
	"musicbrainz": {
        "clientID": your-client-id-here,
        "clientSecret": your-client-secret-here,
        "callbackURL": "http://localhost:9099/cb"
    },
	"session": {
		"maxAge": 2592000000,
		"secret": "secret",
        "secure": false,
        "redis": {
            "host": "127.0.0.1",
            "port": 6379,
            "ttl": 3600
        }
	},
	"database": {
		"client": "pg",
		"connection": {
			"host": "127.0.0.1",
			"database": "bookbrainz",
			"user": "postgres",
            "password": "password"
		}
	},
	"search": {
		"host": "127.0.0.1:9200",
		"httpAuth": "elastic:changeme",
        "apiVersion": "5.5",
        "maxRetries": -1,
        "deadTimeout": 2000
    }
}

Note where it says 127.0.0.1 to point to your local machine instead of the docker container names previously.

As for the port 9200 for elasticsearch, it shouldn’t be changed (unless you have change the default elasticsearch port).
The port 9099 is the one we use to run the webserver, so the configuration you changed makes the webserver call itself trying to connect to elasticsearch :slight_smile:

I hope this clarifies things a bit concerning the configuration!

For the second issue ('.' is not recognized…) I don’t have a Windows 10 machine handy to test anything, which makes it a bit trickier.
Here’s two things I can think of that you can try:

  1. in package.json, wherever you have ./scripts/… replace it with .\scripts\… with a backslash instead of a forward slash.
  2. Use a unix command-line like bash. Windows’ basic command line is not great, and I think that’s why you’re seeing this error. I’ll try to find a better cross-platform solution, but in the meantime you can try using Powershell, or probably better enabling Linux subsystem on windows and using bash natively, or installing another command-line like Cygwin

Let me know how that works out for you

3 Likes

@endurance21

  1. i have installed them
  2. yes, done.
  3. i have changed it to “localhost: 9099”

@Prabhleen
In 3. It is ‘9200’ not ‘9099’
You can see it in @mr_monkey answer Also

@mr_monkey , thanks a lot for you help. It was indeed an error with the host-names, for containers. I might myself have changed them, while trying to solve according to the solutions on internet. And also, i have changed the port from 9200 to 9099.
Now the site loads with all the information, with recent revisions too, just the styling is missing.

I have tried this before also, but get this problem:

for this solution, i will definitely try.
Can ubuntu be used for this?

in app.js, i have written this:

const DEFAULT_PORT = 9099;

@mr_monkey and @endurance21
i more thing, I have installed the ‘flow-for-vscode’ extension but get this:

According to this:

BookBrainz uses Flow as a javascript typechecking library. VSCode is partial to Typescript, and needs to be configured to avoid confusion.
We recommend you install the flow-for-vscode extension and follow this setup step:
Set [VSCode configuration] javascript.validate.enable option to false or completely disable the built-in TypeScript extension for your project

i have done both.

I FIGURED IT!

removed ./ and replaced with node

this gives me:

So, here it can access the file now, but gives an error when encountered with the first line of each. (build-less, build-client)

Just curious, why don’t you use docker. Everything is super simple with docker :stuck_out_tongue:

1 Like

@prabalsingh24 i should have tried that before, but now as my exams are coming near (from 2-8th march), i am already packed with my study schedule, so i get comparatively less time to invest and hence reset everything. :frowning_face:
@mr_monkey, any solution to this?

@Prabhleen
Why don’t you install Ubuntu or VM on your win 10.
I mean it would be easy for development and installing dependencies and also you will learn a lot about bash commands and Linux internals in particular.
Try it, I would suggest :blush:

@endurance21 i have installed dependencies from ubuntu only. But i don’t know how to run the code on ubuntu.
OUTPUT from ubuntu:

@Prabhleen
No worries
First things you have to go to the directory of project and then do :blush:
Npm start

You are doing at home directory now, :sweat_smile:

@endurance21
Now i tried in the project directory, it give same error.
It doesn’t show which version of npm

i tried running the command for version in root, it works:
image

In the user terminal it shows that npm is downloaded in node_modules:

So, first i tried running in VS code, there the error (#! /usr/bin/env node ^SyntaxError: Invalid or unexpected token) can’t be resolved. This error comes from build-less and build-client-js files for styling, everything else is working. I surfed for this a lot but with no success.

Then i tried running in ubuntu, where i downloaded the project and node.js, (npm should have been installed with the nodejs package only, but didn’t and gives the error as above.)
Hence, i was not able to continue with this also.

And now i am going to install Docker using linux and i hope it goes well. :slightly_smiling_face:

@Prabhleen
Have you installed npm using
Sudo apt install npm - g
Have you used global (-g) flag while installing…

That’s the problem. I think.
Please install npm using NVM,
Node version manager.

Go through this, there is a section on page, “How To Install Using NVM”
Also change the version of your Ubuntu if it is 18.04, there is a blue button at starting of page to do so.

2 Likes

THANKS A LOT! IT REALLY SOLVED THE ISSUE.
so, now as my dependencies were running earlier, do i have to install something else like babel?