I am using this VSCode extension frequently to debug chaincodes written in Typescript.
Now I want to test it on my chaincode written in Javascript and this does not work.
I am correctly running my blockchain env with Docker Desktop on my Mac and I have my smart contracts on a folder.
For Typescript, I have my launch.json file written like this:
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "hlf-node",
"request": "launch",
"name": "Debug Smart Contract"
}
]
}
When I press "Debug chaincode" on VS Code, it deploys the chaincode and, once up and running, I launch tests with the test.fabric file, using a syntax like:
{
"invoke": "ClassTokenContract:create",
"args": ["{\"id\":\"1\"}"]
},
Everything works, but if I do the same thing with a Javascript file, I get this error:
Error
Error: Cannot find module 'moment'
Require stack:
- /GitHub/dc/dc-chaincode/dgc/utils/Utils.js
- /GitHub/dc/dc-chaincode/dgc/ERC-1203/lib/classToken.js
- /GitHub/dc/dc-chaincode/dgc/ERC-1203/lib/erc-list-contract.js
- /GitHub/dc/dc-chaincode/dgc/ERC-1203/lib/class-token-contract.js
- /GitHub/dc/dc-chaincode/dgc/ERC-1203/index.js
- /GitHub/dc/dc-chaincode/dgc/ERC-1203/node_modules/fabric-shim/lib/contract-spi/bootstrap.js
- /GitHub/dc/dc-chaincode/dgc/ERC-1203/node_modules/fabric-shim/lib/cmds/metadata/lib/generate.js
- /GitHub/dc/dc-chaincode/dgc/ERC-1203/node_modules/fabric-shim/lib/cmds/metadata.js
- /GitHub/dc/dc-chaincode/dgc/ERC-1203/node_modules/yargs/index.js
- /GitHub/dc/dc-chaincode/dgc/ERC-1203/node_modules/fabric-shim/cli.js
at Function.Module._resolveFilename (/GitHub/dc/dc-chaincode/dgc/ERC-1203/lib/internal/modules/cjs/loader.js:933:15)
at Function.Module._load (/GitHub/dc/dc-chaincode/dgc/ERC-1203/lib/internal/modules/cjs/loader.js:778:27)
at Module.require (/GitHub/dc/dc-chaincode/dgc/ERC-1203/lib/internal/modules/cjs/loader.js:1005:19)
at require (/GitHub/dc/dc-chaincode/dgc/ERC-1203/lib/internal/modules/cjs/helpers.js:102:18)
at Object.<anonymous> (/GitHub/dc/dc-chaincode/dgc/utils/Utils.js:3:16)
at Module._compile (/GitHub/dc/dc-chaincode/dgc/ERC-1203/lib/internal/modules/cjs/loader.js:1105:14)
at Object.Module._extensions..js (/GitHub/dc/dc-chaincode/dgc/ERC-1203/lib/internal/modules/cjs/loader.js:1159:10)
at Module.load (/GitHub/dc/dc-chaincode/dgc/ERC-1203/lib/internal/modules/cjs/loader.js:981:32)
at Function.Module._load (/GitHub/dc/dc-chaincode/dgc/ERC-1203/lib/internal/modules/cjs/loader.js:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {code: 'MODULE_NOT_FOUND', requireStack: Array(10), stack: 'Error: Cannot find module 'moment'
Require st…re (node:internal/modules/cjs/loader:1005:19)', message: 'Cannot find module 'moment'
Require stack:
-…any/ERC-1203/node_modules/fabric-shim/cli.js'}
This is happening only running my contract in local, because on other env and clusters it is working perfectly.
Moment is a package inserted in package.json and used insile a Javascript file which is symlinked into the smart contract folder.
I always used symlinks, also for typescript contracts, and they always worked correctly.
I am using this VSCode extension frequently to debug chaincodes written in Typescript.
Now I want to test it on my chaincode written in Javascript and this does not work.
I am correctly running my blockchain env with Docker Desktop on my Mac and I have my smart contracts on a folder.
For Typescript, I have my launch.json file written like this:
launch.json
When I press "Debug chaincode" on VS Code, it deploys the chaincode and, once up and running, I launch tests with the test.fabric file, using a syntax like:
Everything works, but if I do the same thing with a Javascript file, I get this error:
Error
This is happening only running my contract in local, because on other env and clusters it is working perfectly.
Moment is a package inserted in package.json and used insile a Javascript file which is symlinked into the smart contract folder.
I always used symlinks, also for typescript contracts, and they always worked correctly.