You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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"
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.
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.
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/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] -> ~/tmp/Fabric-IPFS-project/dataCompressWithFabricAndIPFS-master/src
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
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.
The text was updated successfully, but these errors were encountered: