如何解决npm/nodeJS - 从库目录运行时创建的自定义库有效,但当库安装到另一个项目时不起作用
我对我创建的一个小型库感到非常兴奋,该库使用 HardHat 和 Gnache-Cli 来打开本地测试网以进行测试。当我测试在库的 package.json 中创建的命令时,它们都可以正常工作。我随后在 npmjs 上发布了该软件包。
当我尝试在目标项目上执行库中可用的命令时,问题就出现了,因为依赖项似乎缺失并给出了很多奇怪的错误。下图显示了图书馆的不同兴趣点:
基本文件夹结构和依赖项:
完整的 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 举报,一经查实,本站将立刻删除。