0

我一直对我创建的一个小型库感到疯狂,它使用 HardHat 和 Gnache-Cli 来打开本地测试网以进行测试。当我测试在库的 package.json 中创建的命令时,它们都可以正常工作。我后来继续在npmjs上发布包。

当我尝试在目标项目上执行库中可用的命令时,问题就出现了,因为依赖项似乎丢失了并且给出了很多奇怪的错误。下图显示了图书馆的不同兴趣点:

基本文件夹结构和依赖关系: 基本文件夹结构和package.json简要视图

可运行的脚本: 可用的脚本和 bin 条目

本地测试网启动脚本预览 测试网启动脚本

部署合约脚本预览: 部署合约脚本

编译合约脚本预览: 编译合约脚本

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

完整的 package.json 文件:

{
  "name": "@carlos0202/local-testnet-deployer",
  "description": "Setup local testent for Tally Web e2e tests including required smart contracts",
  "version": "1.1.5",
  "author": {
    "name": "Natacha De La Rosa"
  },
  "dependencies": {
    "@gnosis.pm/safe-contracts": "^1.2.0",
    "@nomiclabs/hardhat-web3": "^2.0.0",
    "@openzeppelin/contracts": "^4.0.0",
    "shelljs": "^0.8.4",
    "wait-on": "^6.0.0",
    "web3": "^1.3.6",
    "yargs": "^17.0.1",
    "@ethersproject/abstract-signer": "^5.0.6",
    "@ethersproject/bignumber": "^5.0.8",
    "@nomiclabs/hardhat-ethers": "^2.0.1",
    "@nomiclabs/hardhat-waffle": "^2.0.1",
    "@typechain/ethers-v5": "^5.0.0",
    "@typechain/hardhat": "^1.0.1",
    "app-root-path": "^3.0.0",
    "concurrently": "^6.2.0",
    "ethereum-waffle": "^3.2.0",
    "ethers": "^5.0.32",
    "fs-extra": "^9.0.1",
    "hardhat": "^2.0.10",
    "hardhat-gas-reporter": "^1.0.4"
  },
  "devDependencies": {
    "@commitlint/cli": "^9.1.2",
    "@commitlint/config-conventional": "^9.1.2",
    "@types/app-root-path": "^1.2.4",
    "@types/chai": "^4.2.13",
    "@types/fs-extra": "^9.0.1",
    "@types/mocha": "^7.0.2",
    "@types/node": "^14.17.4",
    "@typescript-eslint/eslint-plugin": "^3.10.1",
    "@typescript-eslint/parser": "^3.10.1",
    "chai": "^4.2.0",
    "commitizen": "^4.2.1",
    "cz-conventional-changelog": "^3.3.0",
    "dotenv": "^8.2.0",
    "eslint": "^7.11.0",
    "eslint-config-prettier": "^6.12.0",
    "husky": "^4.3.0",
    "mocha": "^8.1.3",
    "prettier": "^2.1.2",
    "prettier-plugin-solidity": "^1.0.0-beta.1",
    "solhint": "^3.2.1",
    "solhint-plugin-prettier": "^0.0.5",
    "solidity-coverage": "^0.7.12",
    "ts-generator": "^0.1.1",
    "ts-node": "^8.10.2",
    "typechain": "^4.0.1",
    "typescript": "<4.1.0"
  },
  "files": [
    "/contracts",
    "/scripts",
    "/tasks",
    "/test",
    "/types",
    "governance-contracts-deploy.js",
    "hardhat.config.ts",
    "local-testnet-compile-contracts.js",
    "local-testnet-up.js",
    "testnet-cleanup.js"
  ],
  "keywords": [
    "blockchain",
    "ethereum",
    "hardhat",
    "smart-contracts",
    "solidity",
    "ganache"
  ],
  "license": "WTFPL",
  "publishConfig": {
    "access": "public"
  },
  "scripts": {
    "clean": "hardhat clean",
    "commit": "git-cz",
    "compile": "hardhat compile",
    "coverage": "hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"./test/**/*.ts\"",
    "lint": "yarn run lint:sol && yarn run lint:ts && yarn run prettier:list-different",
    "lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"",
    "lint:ts": "eslint --config ./.eslintrc.yaml --ignore-path ./.eslintignore --ext .js,.ts .",
    "prettier": "prettier --config .prettierrc --write \"**/*.{js,json,md,sol,ts}\"",
    "prettier:list-different": "prettier --config .prettierrc --list-different \"**/*.{js,json,md,sol,ts}\"",
    "test": "hardhat test",
    "typechain": "hardhat typechain",
    "pretestnet:deploy": "node testnet-cleanup.js",
    "testnet:deploy": "concurrently \"node local-testnet-up.js\" \"node governance-contracts-deploy.js\"",
    "testnet:compile": "node local-testnet-compile-contracts.js"
  },
  "bin": {
    "testnet-cli": "cli.js"
  }
}

需要任何帮助!!!

4

0 回答 0