0

I am trying to run the first application following the docs on hyperledger fabric. When I am in asset-transfer-basic/application-javascript , tried to run npm install. It threw an error below:

> npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
> npm WARN deprecated har-validator@5.1.5: this library is no longer supported

> pkcs11js@1.2.0 install /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/pkcs11js
> node-gyp rebuild

> make ✖ ERR  Missing Makefile / Bakefile 
> make ℹ info Run "make init" to generate a Makefile.

> protobufjs@6.10.2 postinstall /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/protobufjs
> node scripts/postinstall

> npm notice created a lockfile as package-lock.json. You should commit this file.
> npm WARN asset-transfer-basic@1.0.0 No repository field.

> added 125 packages from 170 contributors and audited 125 packages in 21.417s

> 4 packages are looking for funding
  > run `npm fund` for details

> found 0 vulnerabilities.

Following the instruction I went to folder node_modules/pkcs11js and ran make init to create Makefile. After that rerun command npm install and node app.js. It still was the same error. Even though I ran npm install -g pkcs11js, it did not solve the problem.

When I ran node app.js , it threw:

internal/modules/cjs/loader.js:968
  throw err;
  ^

Error: Cannot find module './build/Release/pkcs11.node'
Require stack:
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/pkcs11js/index.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-common/lib/impl/bccsp_pkcs11.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-common/lib/User.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-common/index.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/logger.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/impl/query/query.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/transaction.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/contract.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/network.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/gateway.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/index.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/app.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/pkcs11js/index.js:5:16)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/pkcs11js/index.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-common/lib/impl/bccsp_pkcs11.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-common/lib/User.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-common/index.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/logger.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/impl/query/query.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/transaction.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/contract.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/network.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/gateway.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/index.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/app.js'
  ]
}

I have been trying to solve it for a couple of days , still not have any solutions.

Any advices would be much appreciated !!

Viet Ma
  • 3
  • 3
  • In the case of node.js, information about the version is required because there is a version dependency for each module in fabric. – myeongkil kim Jan 05 '21 at 15:23
  • I checked package.json inside fabric-samples and it requires "engines": { "node": ">=12", "npm": ">=5" } I have node version: v12.18.4 and npm version 6.14.10. Or did you mean from the docs ? – Viet Ma Jan 05 '21 at 16:01
  • I am following the article Writing First Application https://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html and have a difficulty with running npm install and node app.js – Viet Ma Jan 05 '21 at 16:09
  • Which version of hyperledger fabric do you want to run? – Hojjat Jashnniloofar Jan 05 '21 at 22:10
  • see [node/issue/102](https://github.com/nodejs/node-report/issues/102) / [node/issue/157](https://github.com/audreyt/node-webworker-threads/issues/157), is not problem in `hyperledger-fabric`. need to add tags(node.js, npm, ...) – myeongkil kim Jan 06 '21 at 12:24
  • My advice would be not to use your windows file system within WSL2. (ie don't do it on /mnt/C) try using the native file system of WSL2 so `work from your WSL2 home directory` ie `cd ~`. The windows file system has a fixed length for paths which may be the cause of your problem – david_k Jan 06 '21 at 16:06
  • Thanks a lot for all your advices. I have solved the problem with this article https://stackoverflow.com/questions/63716587/in-wsl2-ubuntu-20-04-for-windows-10-nodejs-is-installed-but-npm-is-not-working. I just had a wrong path :) – Viet Ma Jan 07 '21 at 18:26

1 Answers1

2

I've had a similar error, but it arose while working on fabcar,

It seems like pkcs11js requires node build-essential package, ie make command to build the packages.

It seems you are using windows OS, find ways to install node build-essential package.

For Ubuntu, It can be installed by running command

$ sudo apt-get install build-essential

Then re-run the command npm install at the root of your node app (where package.json file is located)

daniel ernest
  • 345
  • 3
  • 9