npm/nodejs-从library dir运行时创建的自定义库可以工作,但在将库安装到另一个项目中时不工作

disho6za  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(186)

我一直非常喜欢我创建的一个小型库,它使用hardhat和gnache cli打开本地testnet进行测试。当我测试在库的package.json中创建的命令时,它们都可以正常工作。我随后在NPMJ上发布了该软件包。
当我试图在目标项目上执行库中可用的命令时,问题就出现了,因为依赖项似乎丢失了,并且出现了很多奇怪的错误。以下图像显示了库的不同兴趣点:
基本文件夹结构和依赖项:

要运行的可用脚本:

本地testnet up脚本的预览

部署合同脚本预览:

编译合同脚本预览:

库在安装到另一个项目时抛出随机错误:

完整的package.json文件:

  1. {
  2. "name": "@carlos0202/local-testnet-deployer",
  3. "description": "Setup local testent for Tally Web e2e tests including required smart contracts",
  4. "version": "1.1.5",
  5. "author": {
  6. "name": "Natacha De La Rosa"
  7. },
  8. "dependencies": {
  9. "@gnosis.pm/safe-contracts": "^1.2.0",
  10. "@nomiclabs/hardhat-web3": "^2.0.0",
  11. "@openzeppelin/contracts": "^4.0.0",
  12. "shelljs": "^0.8.4",
  13. "wait-on": "^6.0.0",
  14. "web3": "^1.3.6",
  15. "yargs": "^17.0.1",
  16. "@ethersproject/abstract-signer": "^5.0.6",
  17. "@ethersproject/bignumber": "^5.0.8",
  18. "@nomiclabs/hardhat-ethers": "^2.0.1",
  19. "@nomiclabs/hardhat-waffle": "^2.0.1",
  20. "@typechain/ethers-v5": "^5.0.0",
  21. "@typechain/hardhat": "^1.0.1",
  22. "app-root-path": "^3.0.0",
  23. "concurrently": "^6.2.0",
  24. "ethereum-waffle": "^3.2.0",
  25. "ethers": "^5.0.32",
  26. "fs-extra": "^9.0.1",
  27. "hardhat": "^2.0.10",
  28. "hardhat-gas-reporter": "^1.0.4"
  29. },
  30. "devDependencies": {
  31. "@commitlint/cli": "^9.1.2",
  32. "@commitlint/config-conventional": "^9.1.2",
  33. "@types/app-root-path": "^1.2.4",
  34. "@types/chai": "^4.2.13",
  35. "@types/fs-extra": "^9.0.1",
  36. "@types/mocha": "^7.0.2",
  37. "@types/node": "^14.17.4",
  38. "@typescript-eslint/eslint-plugin": "^3.10.1",
  39. "@typescript-eslint/parser": "^3.10.1",
  40. "chai": "^4.2.0",
  41. "commitizen": "^4.2.1",
  42. "cz-conventional-changelog": "^3.3.0",
  43. "dotenv": "^8.2.0",
  44. "eslint": "^7.11.0",
  45. "eslint-config-prettier": "^6.12.0",
  46. "husky": "^4.3.0",
  47. "mocha": "^8.1.3",
  48. "prettier": "^2.1.2",
  49. "prettier-plugin-solidity": "^1.0.0-beta.1",
  50. "solhint": "^3.2.1",
  51. "solhint-plugin-prettier": "^0.0.5",
  52. "solidity-coverage": "^0.7.12",
  53. "ts-generator": "^0.1.1",
  54. "ts-node": "^8.10.2",
  55. "typechain": "^4.0.1",
  56. "typescript": "<4.1.0"
  57. },
  58. "files": [
  59. "/contracts",
  60. "/scripts",
  61. "/tasks",
  62. "/test",
  63. "/types",
  64. "governance-contracts-deploy.js",
  65. "hardhat.config.ts",
  66. "local-testnet-compile-contracts.js",
  67. "local-testnet-up.js",
  68. "testnet-cleanup.js"
  69. ],
  70. "keywords": [
  71. "blockchain",
  72. "ethereum",
  73. "hardhat",
  74. "smart-contracts",
  75. "solidity",
  76. "ganache"
  77. ],
  78. "license": "WTFPL",
  79. "publishConfig": {
  80. "access": "public"
  81. },
  82. "scripts": {
  83. "clean": "hardhat clean",
  84. "commit": "git-cz",
  85. "compile": "hardhat compile",
  86. "coverage": "hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"./test/**/*.ts\"",
  87. "lint": "yarn run lint:sol && yarn run lint:ts && yarn run prettier:list-different",
  88. "lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"",
  89. "lint:ts": "eslint --config ./.eslintrc.yaml --ignore-path ./.eslintignore --ext .js,.ts .",
  90. "prettier": "prettier --config .prettierrc --write \"**/*.{js,json,md,sol,ts}\"",
  91. "prettier:list-different": "prettier --config .prettierrc --list-different \"**/*.{js,json,md,sol,ts}\"",
  92. "test": "hardhat test",
  93. "typechain": "hardhat typechain",
  94. "pretestnet:deploy": "node testnet-cleanup.js",
  95. "testnet:deploy": "concurrently \"node local-testnet-up.js\" \"node governance-contracts-deploy.js\"",
  96. "testnet:compile": "node local-testnet-compile-contracts.js"
  97. },
  98. "bin": {
  99. "testnet-cli": "cli.js"
  100. }
  101. }

需要任何帮助!!!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题