Path where nodejs is installed in ubuntu

I am new to ubuntu (linux).

I installed nodejs for a project.

Recently I am getting this error on npm install

Error: "pre" versions of node cannot be installed, use the --nodedir flag instead

For this I searched and found a stack link below as

Node pre error

Under the solution it asks for the directory where nodejs is installed and currently i am clueless where the nodejs is installed.

Please help me on how can I locate the directory where nodejs is installed.

You can use which to locate a command. For more information go in the manual: man which.

For your case, type which nodejs.

EDIT: The answer from your link is reffering to the path of node source code, not nodejs binary.