wish helps you That's because load() is asynchronous: it returns right away, performs its work in the background, then calls a user-provided function when its task is complete. The stepping delay gives you the illusion that the function is synchronous and performs all its work before returning. Therefore, you should pass a callback function to load() and perform your subsequent work inside that callback:
help you fix your problem If you want to use relative paths for res.sendFile, you need to specify the root option. Use the following code to serve index.html, assuming it resides in the same directory as the Node app source. You can get the current directory with __dirname.