sorry for my newby question but I want to add a string to ipfs and return the hash to console.
I cant find any example code for node.js in documentation.
I tried this but nothing happened (no console-log).
works fine but I dont have a hash value I need to return the hash.
I found this in another cummunity forum: Note 1: The ipfs.add method is not only capable of uploading files into IPFS, but also data. Feel free to upload any random text to IPFS, such as await (ipfs as IPFSHTTPClient).add('Hello World') .
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in C:\Users\user\Desktop\JQDapp\dappweb\node_modules\ipfs-http-client\package.json
at throwExportsNotFound (node:internal/modules/esm/resolve:472:9)
at packageExportsResolve (node:internal/modules/esm/resolve:693:7)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\user\Desktop\JQDapp\dappweb\index.js:2:20) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Please install this ipfs-http-client package instead with: npm install ipfs-http-client@50.1.2
If you are installing the latest version of ipfs-http-client (57.0.3) with just npm install ipfs-http-client
There are some slight changes on how it is imported referenced here: ipfs-http-client - npm
Please import the latest version of ipfs-http-client using { create } as @kaweendras pointed out.
Hello, IĀ“ve installed npm install ipfs-http-client@50.1.2 package but when I attempted to run the command import('ipfs-http-client'); under Truffle console it still gives me the following error message:
truffle(mainnet_fork)> import(āipfs-http-clientā); Uncaught TypeError: A dynamic import callback was not specified.
at importModuleDynamicallyCallback (node:internal/process/esm_loader:39:9)*
at new NodeError (node:internal/errors:387:5)*
at __node_internal_captureLargerStackTrace (node:internal/errors:477:5) {*