Open larryj52 opened 2 years ago
@larryj52 this issue is related to this repo, but you might be able to avoid this issue by using changing line 2 of utils/nftport/uploadFiles.js
to const fetch = await import("node-fetch");
.
I'll try it.
New error:
error:Error: ENOENT: no such file or directory, open '${basePath}/build/json/${fileName}.json'
What's this about?
This my uploadFiles.js code:
const FormData = require("form-data"); const fetch = require("node-fetch"); const path = require("path"); 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 = 'https://api.nftport.xyz/v0/files';
let options = {
method: 'POST',
headers: {
Authorization: '45411115-ef9a-4390-aad8-f1d572727d62',
},
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/josn/${fileName}.json',
JSON.stringify(metaData, null, 2));
console.log('${json.file_name} uploaded & ${fileName}.jsom updated!');
})
.catch((err) => console.error('error:' + err));
});
This is the return errors:
error:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined error:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined error:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined error:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined error:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined error:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined error:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined error:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined error:Error: ENOENT: no such file or directory, open '${basePath}/build/json/${fileName}.json' error:Error: ENOENT: no such file or directory, open '${basePath}/build/json/${fileName}.json'
@larryj52 on this line:
let rawdata = fs.readFileSync('${basePath}/build/json/${fileName}.json');
change the quotes (') to backticks(`):
let rawdata = fs.readFileSync(`${basePath}/build/json/${fileName}.json`);
Can anyone help with this error message I am getting from trying to use the Upload NFT instructions:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/raad_1/Desktop/NFT Experiment/hashlips_art_engine-1.1.2_patch_v5/node_modules/node-fetch/src/index.js from /Users/raad_1/Desktop/NFT Experiment/hashlips_art_engine-1.1.2_patch_v5/utils/nftport/uploadFiles_1.js not supported. Instead change the require of index.js in /Users/raad_1/Desktop/NFT Experiment/hashlips_art_engine-1.1.2_patch_v5/utils/nftport/uploadFiles_1.js to a dynamic import() which is available in all CommonJS modules. at Object. (/Users/raad_1/Desktop/NFT Experiment/hashlips_art_engine-1.1.2_patch_v5/utils/nftport/uploadFiles_1.js:2:15) { code: 'ERR_REQUIRE_ESM' }
I found comment to update node-fetch, I'm not expert why so, but it worked for me. First run: npm uninstall node-fetch Then: npm install node-fetch@2
Can anyone help with this error message I am getting from trying to use the Upload NFT instructions:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/raad_1/Desktop/NFT Experiment/hashlips_art_engine-1.1.2_patch_v5/node_modules/node-fetch/src/index.js from /Users/raad_1/Desktop/NFT Experiment/hashlips_art_engine-1.1.2_patch_v5/utils/nftport/uploadFiles_1.js not supported. Instead change the require of index.js in /Users/raad_1/Desktop/NFT Experiment/hashlips_art_engine-1.1.2_patch_v5/utils/nftport/uploadFiles_1.js to a dynamic import() which is available in all CommonJS modules. at Object. (/Users/raad_1/Desktop/NFT Experiment/hashlips_art_engine-1.1.2_patch_v5/utils/nftport/uploadFiles_1.js:2:15) {
code: 'ERR_REQUIRE_ESM'
}