Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load UI when Node.js process run from a different directory #300

Closed
thehammeredone opened this issue Jun 23, 2021 · 3 comments
Closed

Comments

@thehammeredone
Copy link

Problem:

For our Node server, we were actually running the process one directory up from the server, and calling node server/server.js, which meant that the bull-board express adapter was looking for the node_modules folder one level higher than where it actually existed (in ./node_modules instead of ./server/node_modules, and we got an error about

unknownErrorHandler Error: Failed to lookup view 'index.ejs' in views directory 'wrong/path/to/node_modules/@bull-board/ui/dist'

when attempting to view the bull-board UI, despite the file actually existing (just not at the path it was looking for).

Further description and possible solution:

I'd never seen this before in another NPM module, so i did some sleuthing, and found that path.resolve uses the CWD of the root process. Since we weren't running from the folder that contained node_modules, the ServerAdapter was getting thrown off.

Most other NPM modules I've seen use __dirname as the root of their path.resolve calls, in order to bypass any problems in finding the node_modules folder for an app by a more "absolute path" means.

The problem lies in https://github.com/felixmosh/bull-board/blob/master/packages/api/src/index.ts on lines 19 & 20 (e.g. the calls to path.resolve()).

I'm not the most seasoned with Node.js, but the resource here: https://www.digitalocean.com/community/tutorials/nodejs-how-to-use__dirname seems to indicate that you'll get the directory for the API package's index.ts, at which point you could use relative paths to get to the rest of what you need?

Hope this helps.

@felixmosh
Copy link
Owner

Thank you for reporting this issue, I'll review possible solutions for it

@felixmosh
Copy link
Owner

Fixed in v3.2.11

@thehammeredone
Copy link
Author

Most excellent!

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants