Open askquestions opened 2 years ago
I have already resolved the issues that I have raised. The solution is to replace the line of import { create } from 'ipfs-http-client' with import { create } from '/usr/local/lib/node_modules/ipfs-http-client/index.js'
Now, I can move into fabricService.js to continue the debugging. It seems to me that the file of fabricService.js is very outdated. For example, the package 'fabric-client' has ben replaced by 'fabric-network'. Thus, all of the APIs related to fabric-client are no longer valid and need to be replaced with APIs in fabric-network.
Have you tried to update the file of fabricService.js? Thanks.
Hello,
I have tried to use the code files in Fabric-IPFS-project/dataCompressWithFabricAndIPFS-master/src and found problems as follows. First of all, I am new to node, npm, etc. I am reading into the documents of node, npm, while I am working with your code files.
1) I got errors on installing ipfs-api. After learning that ipfs-api has been deprecated and is replaced by ipfs-http-client, I switched to install ipfs-http-client and got a successful installation. Then, I learned that I have use the following lines in place of your original code lines in server.js.
new code lines: import { create } from 'ipfs-http-client' const ipfsClient = create() const ipfs = create('http://localhost:5001');
your original code lines: const ipfsAPI = require('ipfs-api'); const ipfs = ipfsAPI('localhost', '5001', {protocol: 'http'});
When I run "node server.mjs", I met another error saying that import { create } from 'ipfs-http-client' ^^^^^^
SyntaxError: Cannot use import statement outside a module
I learned a solution that server.js needs to be renamed into server.mjs. After renaming, this error disappeared.
2) When I run 'node server.mjs', I got error message that
node:internal/process/esm_loader:94 internalBinding('errors').triggerUncaughtException( ^ Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ipfs-http-client' imported from ~/tmp/Fabric-IPFS-project-save/dataCompressWithFabricAndIPFS-master/src/server.mjs Did you mean to import ipfs-http-client/cjs/src/index.js? at new NodeError (node:internal/errors:371:5) at packageResolve (node:internal/modules/esm/resolve:892:9) at moduleResolve (node:internal/modules/esm/resolve:938:18) at defaultResolve (node:internal/modules/esm/resolve:1041:11) at ESMLoader.resolve (node:internal/modules/esm/loader:530:30) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18) at ModuleWrap. (node:internal/modules/esm/module_job:79:40)
at link (node:internal/modules/esm/module_job:78:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
I have already installed ipfs-http-client module whican be seen when I run "npm list -g"
$ npm list -g /usr/local/lib ├── @grpc/grpc-js@1.5.5 ├── async@2.6.2 ├── body-parser@1.19.1 ├── crypto@1.0.1 ├── datacompresswithfabricandipfs@1.0.0 -> ~/tmp/Fabric-IPFS-project/dataCompressWithFabricAndIPFS-master/src ├── express@4.17.2 ├── fabric-network@2.2.11 ├── ipfs-core@0.14.1 ├── ipfs-http-client@56.0.1 ├── ipfs@0.62.1 ├── npm@8.5.0 ├── promised-io@0.3.6 ├── validator@13.7.0 ├── webcrypto-shim@0.1.7 └── yarn@1.22.17
I have already set the environmental variable of $NODE_PATH to point to the node_modules. $ echo $NODE_PATH /usr/local/lib:/usr/local/lib/node_modules
$ ls /usr/local/lib/node_modules -l total 60 drwxr-xr-x 5 root root 4096 Feb 11 16:20 async drwxr-xr-x 4 root root 4096 Feb 11 19:44 body-parser drwxr-xr-x 2 root root 4096 Feb 11 19:43 crypto lrwxrwxrwx 1 root root 88 Feb 11 15:18 datacompresswithfabricandipfs -> ~/tmp/Fabric-IPFS-project/dataCompressWithFabricAndIPFS-master/src drwxr-xr-x 4 root root 4096 Feb 11 19:42 express drwxr-xr-x 5 root root 4096 Feb 12 07:55 fabric-network drwxr-xr-x 3 root root 4096 Feb 12 13:05 @grpc drwxr-xr-x 7 root root 4096 Feb 12 13:11 ipfs drwxr-xr-x 7 root root 4096 Feb 12 14:41 ipfs-core drwxr-xr-x 6 root root 4096 Feb 12 06:15 ipfs-http-client drwxr-xr-x 7 root root 4096 Feb 11 15:16 npm drwxr-xr-x 5 root root 4096 Feb 11 15:58 promised-io drwxr-xr-x 4 root root 4096 Feb 11 19:32 validator drwxr-xr-x 3 root root 4096 Feb 11 17:13 webcrypto-shim drwxr-xr-x 4 root root 4096 Feb 12 16:17 yarn
At this point, I truly got stuck because I could not find any helpful information to resolve this error.
Could you please help me to resolve this error?
Thank you.