类型错误:找不到“@babel”的类型定义文件

Dap*_*ser 2 typescript eslint babeljs next.js

我正在使用以下 package.json 编写下一个项目。

{
  "name": "dapp-boilerplate",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
    "format": "prettier --write . --ignore-path .gitignore ./next-env.d.ts",
    "typechain": "typechain --target ethers-v5 --out-dir ./contracts/types './contracts/*.json'"
  },
  "dependencies": {
    "@types/": "metamask/providers",
    "@types/eslint": "^8.4.8",
    "next": "^12.3.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "@next/eslint-plugin-next": "^13.0.0",
    "@typechain/ethers-v5": "^10.1.0",
    "@types/node": "^18.11.5",
    "@types/react": "^18.0.22",
    "@typescript-eslint/eslint-plugin": "^5.41.0",
    "@typescript-eslint/parser": "^5.41.0",
    "eslint": "^8.26.0",
    "eslint-config-next": "^13.0.0",
    "eslint-config-prettier": "^8.5.0",
    "ethers": "^5.0.31",
    "prettier": "2.7.1",
    "typechain": "^8.1.0",
    "typescript": "^4.1.3"
  }
}

Run Code Online (Sandbox Code Playgroud)

yarn build我有这样的问题。我认为这是由于 eslint 造成的,但这不是正确的原因。有人有解决方案吗?

yarn run v1.22.19
$ next build
info  - Linting and checking validity of types .Failed to compile.

Type error: Cannot find type definition file for '@babel'.
  The file is in the program because:
    Entry point for implicit type library '@babel'

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Run Code Online (Sandbox Code Playgroud)

我尝试部署到 netlify 并遇到意外错误,所以我运行yarn build然后遇到错误。

Sha*_*nan 5

像这样安装 babel 的类型定义文件:

 npm i --save-dev @types/babel
Run Code Online (Sandbox Code Playgroud)

  • 也安装此类型 npm i --save-dev @types/babel__core (5认同)
  • 它不起作用,让我出错 (3认同)