./node_modules/expo-router/_ctx.web.tsx:1:19 中出现错误:找不到模块:无法解析“..\.. pp”

问题描述 投票:0回答:1

我的expo应用程序中的node_modules似乎存在一些依赖关系问题。当尝试查看它时,它不会打开并抛出错误。前几天工作正常,但我相信包已经改变了或者其他什么。错误:


› Open in the web browser...
(node:5684) [DEP_WEBPACK_DEV_SERVER_CONSTRUCTOR] DeprecationWarning: Using 'compiler' as the first argument is deprecated. Please use 'options' as the first argument and 'compiler' as the second argument.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5684) [DEP_WEBPACK_DEV_SERVER_LISTEN] DeprecationWarning: 'listen' is deprecated. Please use the async 'start' or 'startCallback' method.
› Press ? │ show all commands
› Open in the web browser...
› Press ? │ show all commands
WARNING in ./node_modules/expo-router/src/exports.ts:26
export 'ErrorBoundaryProps' (reexported as 'ErrorBoundaryProps') was not found in './views/Try' (possible exports: Try)
  24 | export { ExpoRoot } from "./ExpoRoot";
  25 | export { Unmatched } from "./views/Unmatched";
> 26 | export { ErrorBoundaryProps } from "./views/Try";
  27 | export { ErrorBoundary } from "./views/ErrorBoundary";
  28 |
  29 | // Platform

ERROR in ./node_modules/expo-router/_ctx.web.tsx:1:19
Module not found: Can't resolve '..\..\app'
> 1 | export const ctx = require.context(
    |                   ^
  2 |   process.env.EXPO_ROUTER_APP_ROOT!,
  3 |   true,
  4 |   /.*/,

web compiled with 1 error and 1 warning

这是我的 package.json 的样子:

{
  "name": "logintest",
  "version": "1.0.0",
  "main": "expo-router/entry",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@expo/webpack-config": "^19.0.0",
    "@react-navigation/bottom-tabs": "^6.5.11",
    "@react-navigation/drawer": "^6.6.6",
    "@types/react": "~18.2.14",
    "expo": "~49.0.13",
    "expo-constants": "~14.4.2",
    "expo-linking": "~5.0.2",
    "expo-router": "^2.0.0",
    "expo-status-bar": "~1.6.0",
    "react": "18.2.0",
    "react-native": "0.72.6",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-popup-menu": "^0.16.1",
    "react-native-reanimated": "~3.3.0",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-svg": "13.9.0",
    "react-native-web": "~0.19.6",
    "typescript": "^5.1.3"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/webpack-env": "^1.18.4",
    "react-native-svg-transformer": "^1.1.0",
    "sharp-cli": "^2.1.0",
    "source-map-support": "^0.5.21"
  },
  "private": true
}

我尝试了不同版本的节点以及上面列出的各种不同版本的软件包。

请帮忙!

expo node-modules package.json expo-router
1个回答
0
投票

我今天遇到了这个问题,并通过添加解决了这个问题:

    plugins: ['expo-router/babel'],

致我的

babel.config.js
,例如:

/* eslint-env node */
module.exports = function (api) {
  api.cache(true)
  return {
    presets: ["babel-preset-expo"],
    plugins: ['expo-router/babel'],
  }
}

快速入门指南确实为

expo <= 49
指定了这一点,但默认情况下它显示了
expo@50
的内容,但我错过了。

On

expo@50
根据文档,不应需要此插件。

© www.soinside.com 2019 - 2024. All rights reserved.