Gotrue-js throws error when importing

It’s one way, not the only way. Netlify Identity basically uses simple APIs, so you can technically use it without any library. As example being: Examples of Netlify Identity w/o the widget

Anyways, your code has several issues, which is why this is not working. Firstly, you should never commit node_modules to your git repo. Then, instead of importing the file from relative references to node_modules, you should instead use import GoTrue from 'gotrue-js'. Finally, to actually make that JavaScript usable in browser, you need to add a JavaScript bundler like esbuild to resolve, import and bundle the dependencies in a script that the browsers can run.