【问题标题】:Type error: Cannot find type definition file for '@babel'类型错误:找不到 \'@babel\' 的类型定义文件
【发布时间】:2022-11-03 19:52:56
【问题描述】:

我正在使用以下 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"
  }
}

我对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.

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

【问题讨论】:

    标签: typescript next.js babeljs eslint


    【解决方案1】:

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

     npm i --save-dev @types/babel
    

    【讨论】:

    • 它没有用,让我出错
    • 安装这种类型也 npm i --save-dev @types/babel__core
    猜你喜欢
    • 1970-01-01
    • 2019-07-10
    • 2021-05-14
    • 1970-01-01
    • 2022-10-20
    • 2018-02-24
    • 2018-03-09
    • 2018-07-20
    • 2019-05-11
    相关资源
    最近更新 更多