首页 > 解决方案 > 无法从 `node_modules\@jest\console\build\BufferedConsole.js` 解析模块 `assert`:在项目中找不到断言

问题描述

我开始在我工作的 react-native 应用程序上突然出现这个错误。我已经尝试了所有可能的解决方案来解决其他问题,比如清除缓存,但几乎没有对我有用。

即使我尝试运行我以前的工作应用程序并创建新应用程序,但所有人都遇到了同样的错误。

如果您需要任何进一步的细节来调查这个问题,请告诉我。任何形式的帮助将不胜感激。

提前致谢。

下面是我的 package.json

{
  "name": "MyApp",
  "version": "0.0.1",
  "private": true,
  "rnpm": {
    "assets": [
      "./assets/fonts"
    ]
  },
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "clean": "react-native-clean-project"
  },
  "dependencies": {
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/bottom-tabs": "^5.9.1",
    "@react-navigation/drawer": "^5.9.2",
    "@react-navigation/material-bottom-tabs": "^5.2.18",
    "@react-navigation/native": "^5.7.5",
    "@react-navigation/stack": "^5.9.2",
    "react": "16.13.1",
    "react-native": "0.63.2",
    "react-native-clean-project": "^3.4.0",
    "react-native-gesture-handler": "^1.8.0",
    "react-native-reanimated": "^1.13.1",
    "react-native-safe-area-context": "^3.1.8",
    "react-native-screens": "^2.11.0",
    "react-native-splash-screen": "^3.2.0",
    "react-native-tab-view": "^2.15.1",
    "react-native-vector-icons": "^7.1.0",
    "react-native-webview": "^10.9.0"
  },
  "devDependencies": {
    "@babel/core": "^7.8.4",
    "@babel/runtime": "^7.8.4",
    "@react-native-community/eslint-config": "^1.1.0",
    "babel-jest": "^25.1.0",
    "eslint": "^6.5.1",
    "jest": "^25.1.0",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

标签: react-nativejestjsnode-modulesassert

解决方案


推荐阅读