Running node.js and dependencies

@mr_monkey
Here is the output that i got after running the code on node.js.(i was getting this same error earlier also, before setting up dependencies and DB)
According to the manual on the site, [it says make sure that the dependencies are running] i have installed them and made sure that they were running then on ubuntu.
What additional commands do i have to run in addition to this:

npm start – --config ./config/config.json

Also, i am only getting a basic website with no CSS at all when i tried to connect.

1 Like

There’s a couple of different things happening here I think.

The first issue is with the configuration file. The file you pass for configuration is set up for use with docker. For running dependencies yourself, you’ll want to make a copy of config/config.local.json.example, remove .example and modify it according to this section.
Now you can start the server with npm start -- --config ./config/config.local.json and you should be all set.

The second thing that happens is an error thrown in the building process ('.' is not recognized as an internal or external command, operable program or batch file.).
The build-less and build-client-js tasks fail, which is why you’re seeing the website without proper css styles.
I’m not 100% certain of the issue here, but I assume from the error message it has to do with how the tasks are called. What operating system are you running this in? It doesn’t seem to like those ./scripts/… paths !

You can try changing in package.json these two lines to remove the ./ before scripts, then try again. Hopefully that’ll solve the issue, in which case we’ll need to change all those occurrences in that file.

2 Likes

@mr_monkey

The first issue is with the configuration file. The file you pass for configuration is set up for use with docker. For running dependencies yourself, you’ll want to make a copy of config/config.local.json.example , remove .example and modify it according to this section .

Doing this, nothing changed.

I disovered that there was the problem in ports, i.e., i had to enter: 9099 but there was :9200 present in someareas, and i changed that errors at the bottom into warnings.
Previous errors into Present warnings

this also didn’t help in anything. i also tried doing the backslash as it was a suggested solution for this error but that also didn’t work.
I am operating on Windows 10 pro.

@Prabhleen
No worries at all!
We are using git submodules for our stylesheet
Submodule created by @mr_monkey that is lobes.
So init and update the submodules for css.

Do following steps:

  1. git Submodule init
    2.git Submodule update.

And wolla!

1 Like

This also happens when there is no internet connection LOL.

1 Like

@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 https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (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: