The questioner probably thought that Node.js is the same as PHP. By uploading the file directly to the server, you can access a certain URL to run the program, so he naturally struggled with the issue of relative paths.
In fact, the routing of Node.js is registered through a program. Instead of accessing an address like /ooxx/xxoo.js, it is to run the ooxx/xxoo.js file. Similarly, static resource files are generally registered through the static middleware. to specify the root directory, so the specific method depends on how your program is written.
The root directory of the server is the root directory, build is just a folder, equivalent to a path
The questioner probably thought that Node.js is the same as PHP. By uploading the file directly to the server, you can access a certain URL to run the program, so he naturally struggled with the issue of relative paths.
In fact, the routing of Node.js is registered through a program. Instead of accessing an address like
/ooxx/xxoo.js
, it is to run theooxx/xxoo.js
file. Similarly, static resource files are generally registered through thestatic
middleware. to specify the root directory, so the specific method depends on how your program is written.