I tried to load an image file I pack with my node but if I
Jimp.read("./test.png")
or
Jimp.read("test.png")
I get "Error: ENOENT: no such file or directory, open './test.png'" even though it is right beside the js file
I tried to load an image file I pack with my node but if I
Jimp.read("./test.png")
or
Jimp.read("test.png")
I get "Error: ENOENT: no such file or directory, open './test.png'" even though it is right beside the js file
__dirname
is local to each module. Use path.resolve and path.join to get full path to files relative to your node module.
var path = require("path");
var imagePath = path.join(__dirname, "test.png");
Jimp.read(imagePath)
Works thank for the help.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.