Running node.js and dependencies

@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?

@Prabhleen
Good to hear that, finally! :sweat_smile:

No need to install babel.
All you need to do is go to the directory,
And type command ‘npm install’, it will automatically download all essential dependencies…

1 Like

Hi everyone! apologies for delay in reply and no updates. :confused:
As my exams start tomorrow (2.3.19) and will continue till Saturday (7.3.19), i will not be able to participate or contribute to BookBrainz.
i will shortly resume from Sunday (8.3.19)
Thank You.
@mr_monkey

1 Like