找不到Vue本机模块:无法解析'../../App'

时间:2020-07-14 12:06:35

标签: javascript vue-native expo-cli

我尝试开始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.vue,但是我也遇到了问题。

请,请,帮帮我!

1 个答案:

答案 0 :(得分: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 来测试/运行。