npm/nodeJS - 从库目录运行时创建的自定义库有效,但当库安装到另一个项目时不起作用

问题描述

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

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

基本文件夹结构和依赖项:

basic folder structure and package.json brief view

可运行的脚本:

available scripts and bin entry

本地testnet up脚本预览

testnet up script

部署合约脚本预览:

Deploy contracts script

编译合约脚本预览:

Compile contracts script

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

errors from library

完整的 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,"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"
  }
}

需要任何帮助!!!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...