So i was trying to run a test script that should pin a test file using “@textile/eth-storage”, but it gives an error saying
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/mats/blockchain/pinFile/node_modules/@textile/eth-storage/dist/esm/registry' imported from /home/mats/blockchain/pinFile/node_modules/@textile/eth-storage/dist/esm/index.js
To Reproduce
test.js (the script)
import { config } from "dotenv";
import { providers, Wallet } from "ethers";
import { init } from "@textile/eth-storage";
config();
const pinFile = async (file) => {
try {
const rpcURL = "https://rpc-mumbai.maticvigil.com";
const provider = new providers.JsonRpcProvider({ url: rpcURL });
const wallet = new Wallet(process.env.privateKey, provider);
const storage = await init(wallet);
await storage.addDeposit();
const blob = new Blob(["Hello, world!"], { type: "text/plain" });
const file = new File([blob], "welcome.txt", {
type: "text/plain",
lastModified: new Date().getTime(),
});
const { id, cid } = await storage.store(file);
console.log(cid);
const { request, deals } = await storage.status(id);
console.log(request.status_code);
console.log([...deals]);
return cid;
} catch (err) {
console.log(err);
}
};
pinFile().then(data => {
console.log(data);
}).catch(err => {
console.log(err);
});
package.json
{
"name": "pinfile",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@textile/eth-storage": "^0.1.0",
"dotenv": "^10.0.0",
"ethers": "^5.4.6"
},
"type": "module"
}