尝试创建发行包时,无法解析模块"AccessibilityInfo"

pra*_*dha 31 bundle react-native

我在跑步

react-native bundle --platform windows --dev false --entry-file index.windows.js --bundle-output windows/app/ReactAssets/index.windows.bundle --assets-dest windows/app/ ReactAssets/
Run Code Online (Sandbox Code Playgroud)

命令创建发行包,但我收到以下错误

Unable to resolve module `AccessibilityInfo` from `C:\Users\godha.pranay\project\node_modules\react-native\Libraries\react-native\react-native-implementation.js`: Module does not exist in the module map



This might be related to https://github.com/facebook/react-native/issues/4968

To resolve try the following:

  1. Clear watchman watches: `watchman watch-del-all`.

  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.

  3. Reset Metro Bundler cache: `rm -rf $TMPDIR/react-*` or `npm start -- --reset-cache`.  4. Remove haste cache: `rm -rf $TMPDIR/haste-map-react-native-packager-*`.
Run Code Online (Sandbox Code Playgroud)

我尝试了互联网上推荐的一切,没有任何工作.我完全坚持下去了.请帮忙.

mr *_*r L 69

这似乎是0.56中与依赖关系相关的错误."解决方案"是找到依赖项版本的正确组合.我们通过完全安装这些版本找到了一种解决方法:

react-native >> 0.55.4
babel-core >> latest 
babel-loader >> latest
babel-preset-react-native >> 4.0.0
Run Code Online (Sandbox Code Playgroud)

所以你必须按顺序运行这些命令:

react-native init AwesomeProject
cd AwesomeProject
react-native run-android
npm uninstall react-native
npm install --save react-native@0.55.4
react-native run-android
npm install --save babel-core@latest babel-loader@latest
npm uninstall --save babel-preset-react-native
npm install --save babel-preset-react-native@4.0.0
react-native run-android
Run Code Online (Sandbox Code Playgroud)


小智 16

如果您运行的是响应式本机版本0.56.0,则将其降级为0.55.4.

cd "on your project directory"
npm install react-native@0.55.4
Run Code Online (Sandbox Code Playgroud)

如果您想知道原因,请遵循此问题.


Rai*_*bam 9

我遇到过同样的问题.

以前我的反应原生版本是

C:\WINDOWS\system32>react-native -v
react-native-cli: 2.0.1
react-native: 0.56.0
Run Code Online (Sandbox Code Playgroud)

然后我卸载react-native

C:\WINDOWS\system32>npm uninstall -g react-native-cli
removed 41 packages in 3.999s
Run Code Online (Sandbox Code Playgroud)

然后我安装了react-native

npm install react-native@0.55.4
Run Code Online (Sandbox Code Playgroud)

再次入侵

npm install -g react-native-cli@1.2.0
Run Code Online (Sandbox Code Playgroud)

然后这个创建react-native项目的安装工作

react-native init --version="0.55.4" myprojectname
Run Code Online (Sandbox Code Playgroud)


Ume*_*iya 6

    "dependencies": {
        "react": "^16.4.1",
        "react-native": "^0.55.4"
      },
    "devDependencies": {
        "babel-preset-react-native": "^4.0.0",
      },
Run Code Online (Sandbox Code Playgroud)

然后点击以下命令

    npm update
    npm cache clean --force
    cd android
    gradlew clean
    cd..
    react-native run-android
Run Code Online (Sandbox Code Playgroud)

为我工作


Khu*_*ari 5

我还发现了最新的本机0.56.0错误。我试图降级,但仍然无法为我工作。Windows操作系统中的此问题不在Mac中。

简单我尝试过:

react-native init ProjectName --version=0.55.4
Run Code Online (Sandbox Code Playgroud)

一切正常。