【问题标题】:Vue-native Module not found: Can't resolve '../../App'未找到 Vue 原生模块:无法解析 '../../App'
【发布时间】:2020-11-03 18:25:39
【问题描述】:

我尝试启动 vue-native。

$npm install -g vue-native-cli expo-cli

在我的项目中,我安装了

$ npm install vue-native-core vue-native-helper --save
$ npm install vue-native-scripts --save-dev

我创建 vueTransformerPlugin.js 和 metro.config.js 就像指南告诉我的那样 [https://vue-native.io/docs/installation.html][1]

当我启动项目时,我有这个问题

$ npm run web

web 编译失败。 //vueexpocli/node_modules/expo/AppEntry.js 找不到模块:无法在“//vueexpocli/node_modules/expo”中解析“../../App”

看了很多论坛

// app.json
        {
      "expo": {
        "name": "vueexpocli",
        "slug": "vueexpocli",
        "version": "1.0.0",
        "orientation": "portrait",
        "icon": "./assets/icon.png",
        "splash": {
          "image": "./assets/splash.png",
          "resizeMode": "contain",
          "backgroundColor": "#ffffff"
        },
        "updates": {
          "fallbackToCacheTimeout": 0
        },
        "assetBundlePatterns": [
          "**/*"
        ],
        "ios": {
          "supportsTablet": true
        },
        "web": {
          "favicon": "./assets/favicon.png"
        },
        "packagerOpts": {
          "config": "metro.config.js",
          "sourceExts": [
            "vue",
            "js",
            "json",
            "ts",
            "tsx"
          ]
        }
      }
    }
//package.json
    {
      "main": "node_modules/expo/AppEntry.js",
      "scripts": {
        "start": "expo start",
        "android": "expo start --android",
        "ios": "expo start --ios",
        "web": "expo start --web",
        "eject": "expo eject",
        "lint": "eslint ./src ./App.vue --ext .js,.vue",
        "lint:fix": "eslint ./src ./App.vue --ext .js,.vue --fix"
      },
      "dependencies": {
        "expo": "~38.0.8",
        "expo-status-bar": "^1.0.2",
        "react": "~16.11.0",
        "react-dom": "~16.11.0",
        "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
        "react-native-web": "~0.11.7",
        "vue-native-core": "^0.1.4",
        "vue-native-helper": "^0.1.4",
        "vue-native-router": "~0.1.1"
      },
      "devDependencies": {
        "babel-eslint": "^10.0.3",
        "eslint": "^6.5.1",
        "eslint-config-prettier": "^6.4.0",
        "eslint-plugin-prettier": "^3.1.1",
        "eslint-plugin-react": "^7.16.0",
        "eslint-plugin-vue": "^5.2.3",
        "jest-expo": "^35.0.0",
        "prettier": "^1.18.2",
        "react-test-renderer": "16.8.6",
        "vue-native-scripts": "~0.1.4"
      },
      "private": true
    }

我将 App.js 重命名为 App.vue 并更改

// App.vue
    <template>
      <view class="container">
        <text class="text-color-primary">My Vue Native App</text>
      </view>
    </template>
    
    <style>
    .container {
      background-color: white;
      align-items: center;
      justify-content: center;
      flex: 1;
    }
    .text-color-primary {
      color: blue;
    }
    </style>

你有什么想法吗? 我看到很多论坛。 我尝试将 AppEntry.js App 中的 App 重命名为 App.vue,但我也遇到了问题。

请,请,帮助我!

【问题讨论】:

  • 我遇到了同样的问题,你解决了吗?如果是,你是怎么做的?谢谢

标签: javascript vue-native expo


【解决方案1】:

我相信(截至这篇文章)vue-native web 模式目前已被破坏 https://github.com/GeekyAnts/vue-native-core/issues/268

https://github.com/GeekyAnts/vue-native-core/issues/235具体错误信息)

问题已经公开了一段时间,所以希望在 2021 年得到解决:D

现在只需要以 android/ios 而不是 web 的方式测试/运行。

【讨论】:

    猜你喜欢
    • 2021-07-17
    • 2018-04-17
    • 2018-10-01
    • 2020-08-27
    • 2020-12-15
    • 2020-08-20
    • 2021-10-16
    • 2019-07-29
    • 1970-01-01
    相关资源
    最近更新 更多