wazuh / wazuh-api

Wazuh - RESTful API
https://wazuh.com
GNU General Public License v2.0
69 stars 57 forks source link

Wazuh error when tying to start #421

Closed tmaster8 closed 5 years ago

tmaster8 commented 5 years ago

Wazuh error

and I know this is the error handling for app.js wazuh app

AdriiiPRodri commented 5 years ago

Hi @tmaster8,

Thank you very much for your time, let's investigate this problem. Could you please tell me which operating system and the version number of it?

Did this error happen following the Wazuh API installation guide? Wazuh installation guide. Inside the previous link we must choose our operating system and follow the specified steps.

In any case I wait for your answer so I can help you with this problem.

Best regards, Adri

tmaster8 commented 5 years ago

@AdriiiPRodri Amazon AMI Linux 2. yes this error happened following the guide.

AdriiiPRodri commented 5 years ago

I see, let's see why this can happen in your system, can you please run these commands and show me the output?

node --version
npm -g ls --depth=0

When you installed node, did you do it as root user?

tmaster8 commented 5 years ago

@AdriiiPRodri I assume it has to do with http-auth? Yes I installed it as a root user node http

AdriiiPRodri commented 5 years ago

Yes, it has to do with that module. I see that the current version of node installed on your system is node 6.17.1. I recommend you install version 8.x of node. In any case we are going to try to solve it, let's execute the following command and see what it returns to us:

ls -lth /var/ossec/api/node_modules/ 
tmaster8 commented 5 years ago

@AdriiiPRodri node node 2 node 3

AdriiiPRodri commented 5 years ago

Ok @tmaster8, the module seems to be correct in your installation, however let's try the following:

1º Let's remove the module from the API:

rm -r /var/ossec/api/node_modules/http-auth/

2º Now we will reinstall the module:

npm install --prefix /var/ossec/api http-auth

3º Restart the API and check if the error persists

tmaster8 commented 5 years ago

@AdriiiPRodri Problem still persists

AdriiiPRodri commented 5 years ago

All right, it looks like everything is right, let's try running the following:

npm config set user 0 

And then restart the API

tmaster8 commented 5 years ago

@AdriiiPRodri npm

AdriiiPRodri commented 5 years ago

Let's go to the path /var/ossec/api:

cd /var/ossec/api

And run the following command to be able to check that its output is correct:

npm install
tmaster8 commented 5 years ago

@AdriiiPRodri I wish it gave me a better error message.... npm

AdriiiPRodri commented 5 years ago

I think this may be happening in another part of the code. Let's do one:

ls -lth /var/ossec/api/helpers

And we'll see if everything is correct in this folder.

tmaster8 commented 5 years ago

@AdriiiPRodri image

AdriiiPRodri commented 5 years ago

All right in this folder, let's see the contents of the http-auth folder:

ls -lth /var/ossec/api/node_modules/http-auth

And then:

ls -lth /var/ossec/api/node_modules/http-auth/src
tmaster8 commented 5 years ago

@AdriiiPRodri auth

AdriiiPRodri commented 5 years ago

Ok @tmaster8, I see that the permissions on these files are not correct. Let's do the following, as a root user we will execute the following commands:

rm -rf /var/ossec/api/node_modules/*

After this we are going to do the following:

cd /var/ossec/api

The next thing is to reinstall all dependencies:

npm install

Finally, we restart the API

tmaster8 commented 5 years ago

@AdriiiPRodri new error code wazuh

AdriiiPRodri commented 5 years ago

This is unusual, we are going to confirm that everything has gone correctly. Let's list the elements of /var/ossec/api/node_modules:

ls -lth /var/ossec/api/node_modules
tmaster8 commented 5 years ago

@AdriiiPRodri image image image image image

tmaster8 commented 5 years ago

@AdriiiPRodri Nvm I figured it out! Thanks for the help!

AdriiiPRodri commented 5 years ago

Great @tmaster8, I'm so glad I helped you. In order to help other users, you could tell me what the error was, have you installed nvm, have you changed the version of node?

tmaster8 commented 5 years ago

@AdriiiPRodri after following all your steps, I just completely uninstalled and re-installed the wazuh-api via yum