Skip to content Skip to sidebar Skip to footer

Which Context Is The Path Relative To?

This is a dead simple question and no doubt a duplicate but I've searched around and haven't found an answer which works. (Also I am a refugee from the world of Flex/Actionscript a

Solution 1:

Try to

console.log(__dirname)

you will see that it is not index.html you are starting with but main.js. You have to start with the path of the server or main script of your program. In your case it is main.js. So the following should work:

./app/assets/house.jpg

But using __dirname is a good solution and even better it would be using path.join.

Post a Comment for "Which Context Is The Path Relative To?"