I have a problem, I know nothing about programming and I want to make an nft collection, I am following this youtube video: https://www.youtube.com/watch?v=AaCgydeMu64
everything went fine until around (32:14) My text is identical to the one in the video so i dont understand what is going on. When i run the comand: node utils/nftport/uploadFile.js
it says:
const fetch = require("node-fetch");
^
Error [ERR_REQUIRE_ESM]: require() of ES Module ......\hashlips_art_engine-main\node_modules\node-fetch\src\index.js from ......\hashlips_art_engine-main\utils\nftport\uploadFile.js not supported.
Instead change the require of index.js in ......\hashlips_art_engine-main\utils\nftport\uploadFile.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> ......\hashlips_art_engine-main\utils\nftport\uploadFile.js:2:15) {
code: ?[32m'ERR_REQUIRE_ESM'?[39m
NB!: (......) is just a writing replacement for the file that was supposed to be there
This is the code for uploadFile.js:
const FormData = require("form-data");
const fetch = require("node-fetch");
const basePath = process.cwd();
const fs = require("fs");
fs.readdirSync(`${basePath}/build/images`).forEach((file) => {
const formData = new FormData();
const fileStream = fs.createReadStream(`${basePath}/build/images/${file}`);
formData.append("file", fileStream);
let url = "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉";
let options = {
method: 'POST',
headers: {
Authorization: '▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉',
},
body: formData
};
fetch(url, options)
.then(res => res.json())
.then(json => {
const fileName = path.parse(json.file_name).name;
let rawdata = fs.readFileSync(`${basePath}/build/json/${fileName}.json`);
let metaData = JSON.parse(rawdata);
metaData.file_url = json.ipfs_url;
fs.writeFileSync(`${basePath}/build/json/${fileName}.json`,JSON.stringify(metaData, null, 2));
console.log(`${json.file_name} upload & ${fileName}.jsonupdated!`);
})
.catch(err => console.error('error:' + err));
I've been stuck here forever and I feel like I have tried everything, but I know nothing about programming so I find this really hard! I've tried different versions of Node (I think) I've read all around the internett for solutions but nothing works! Please help me and please explain it simple so that I understand. Thanks!