hardhat、truffle、brownie、react 停止工作了?!?错误命令失败,退出代码为 1

hardhat, truffle, brownie, react stopped working?!? error Command failed with exit code 1

我在和 brownie 一起工作,一切都很顺利,推出了我的第一个 useDapp 应用程序,这很有趣。我想看看 truffle 是关于什么的,并通过 npm 安装了它,但出现了一堆警告,而且它在功能方面似乎并不顺利,所以我可能通过 yarn 安装了它,希望包安装程序能够解决问题。它工作了一段时间,然后在迁移时开始超时,而经过测试的代码过去启动得很好?我认为这可能是错误或某种形式的重叠安装。我转向 hardhat 并通过 NPM 安装它,但它无法编译,所以我通过 Yarn 安装它,它编译得很好。我继续创建一个新文件,并在初始化新文件和设置根目录时不小心点击了 Esc。介于两者之间的某个地方,我尝试安装 shorthand 但它没有用。当我输入 hh --help 时,它只打开了一个 Windows 帮助 window 而不是调用 hardhat。在那之后,我无法通过 yarn hardhatnpx hardhat 在文件外部调用 hardhat ....以前无法编译的文件仍然能够通过 npx hardhat compile 编译? 有时会说“找不到模块”,有时会说有关本地安装的问题。

我有点沮丧,想多玩 React,当我开始 yarn 时,我收到一条错误消息。我按照提示进行操作,但没有用,我用谷歌搜索了一下,但没有找到他们共同的解决方案。我尝试升级 eslint 甚至安装 7.11.0,它一直说我有 5.16.0 版本?

编辑:不确定它是否相关,我试图将我的纱线更新到 1.22.17,它说它确实如此,尽管它说我 运行 1.22.15.

windows 7 节点 = v12.13.0 npm =6.12.0

The react-scripts package provided by Create React App requires a dependency:

  "eslint": "^7.11.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of eslint was detected higher up in the tree:

  C:\Users\Nancy\node_modules\eslint (version: 5.16.0)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if C:\Users\Nancy\node_modules\eslint is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls eslint in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed eslint.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

error Command failed with exit code 1.

有点尴尬,答案在错误消息中。

6. Check if C:\Users\Nancy\node_modules\eslint is outside your project directory.
 For example, you might have accidentally installed something in your home folder.

Hardhat 将 root 设置在错误的目录中,我最终在父目录中找到了一个 node_module 文件夹,该文件夹搞砸了

通过 yarn add global truffle 全局重新安装了 truffle,运行 顺利。显然,truffle 与某些 NPM 版本兼容。

Hardhat 似乎还不支持全局安装。通过 yarn add -D hardhat

在本地安装到每个单独的 hardhat 项目中,它运行良好

如果不先调用 yarn,我无法让 shorthand 工作,例如 yarn hh <command>