0

i want to store files of type image in ipfs with node js without using any gateway like pinata , i have tried to install "ipfs-http-client" and "ipfs-core" but i always get an error Module not found for these two libraries . I've installed many version of the libraries and always get the same error . I have installed and runned a local ipfs node and still get the same error. I am really blocked for days now . Before, i have used pinata but now when using the same endpoints i have used before i get the error : {"error":{"reason":"INVALID_ROUTE","details":"The provided route does not match a valid Pinata endpoint"}} even though the same routes worked for me one month ago . This is the code i have tried to try ipfs-http-client

const IPFSClient = require("ipfs-http-client");

const ipfs = IPFSClient({ host: "localhost", port: 5001, protocol: "http" });

router.post("/add-to-ipfs", async (req, res) => {
 const file = await ipfs.add({
  path: "hello.txt",
  content: Buffer.from("Hello, IPFS!"),
  });
 console.log(file.path, file.hash);
 res.send(file.hash);
});

but i always get the error Unable to resolve path to module 'ipfs-http-client' or Module not found even though it exists in package.json and node_modules . I'll appreciate a lot if someone hep me .

Ghost
  • 318
  • 2
  • 8

0 Answers0