无法识别JS服务器,继续构建 [英] JS server not recognized, continuing with build

查看:92
本文介绍了无法识别JS服务器,继续构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境

Windows 10

Windows 10

Npm 5.5.1

Npm 5.5.1

react-native-cli 2.0.1

react-native-cli 2.0.1

本机0.50.3

Genymotion Google Nexus 7-6.0.0 API 23

Genymotion Google Nexus 7 - 6.0.0 API 23

Android内容:

SDK版本:26

buildToolsVersion '26 .0.2'

buildToolsVersion '26.0.2'

TargetsdkVersion:26

TargetsdkVersion: 26

编译"com.android.support:appcompat-v7:26.0.2"

compile "com.android.support:appcompat-v7:26.0.2"

我已经运行了npm start --reset-cache以及react-native start --reset-cache,但是我一直无法识别JS服务器,继续进行构建.这样可以防止打包程序在我的仿真器上运行之前将资产捆绑在一起.

I have run npm start --reset-cache as well as react-native start --reset-cache but I keep getting the JS server not recognized, continuing with build. This prevents the packager bundling the assets before running on my Emulator.

我在这篇文章中遵循了解决方案1:

I have followed solution 1 on this post:

https://github.com/facebook/react-native/issues/9136#issuecomment-306486102

以及这一个:

无法识别JS服务器

我使用本机init APP启动了这个项目.已经无法使用此错误进行构建.使用npm cache clean和react-native start --reset-cache检查此处和其他提到的站点上的serval帖子,这似乎并没有帮助我保持同样的错误.我一次运行得很顺利,但是我更改了一个npm程序包,我想我又把它弄坏了.任何帮助,将不胜感激.我还更新了gradle版本并将其同步到项目中

I started this project with react-native init APP. Already having trouble building it with this error. checking serval posts on here and other sites mentioned using npm cache clean and react-native start --reset-cache and that did not seem to help I keep getting the same error. I had it running smoothly at one time but I altered an npm package and I think I broke it again. any help would be appreciated. I also updated the gradle version and synced that into the project

这里有一些我正在经历的屏幕截图...

Heres some screenshots of what I am experiencing...

**代码**

index.js

import { AppRegistry } from 'react-native';
import App from './App';

AppRegistry.registerComponent('hihi', () => App);

App.js /** *示例React Native应用 * https://github.com/facebook/react-native * @流动 */

App.js /** * Sample React Native App * https://github.com/facebook/react-native * @flow */

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View
} from 'react-native';

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' +
    'Cmd+D or shake for dev menu',
  android: 'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

export default class App extends Component<{}> {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit App.js
        </Text>
        <Text style={styles.instructions}>
          {instructions}
        </Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

app.json

{
  "name": "hihi",
  "displayName": "hihi"
}

.babelrc

{
  "presets": ["react-native"]
}

package.json

{
    "name": "hihi",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "start": "node node_modules/react-native/local-cli/cli.js start",
        "test": "jest"
    },
    "dependencies": {
        "react": "16.0.0",
        "react-native": "0.50.3",
        "watchman": "^0.1.8"
    },
    "devDependencies": {
        "babel-jest": "21.2.0",
        "babel-polyfill": "^6.26.0",
        "babel-preset-es2015": "^6.24.1",
        "babel-preset-react-native": "4.0.0",
        "babel-register": "^6.26.0",
        "jest": "21.2.1",
        "react-test-renderer": "16.0.0"
    },
    "jest": {
        "preset": "react-native"
    }
}

UPDATE UPDATE

我知道了,这是此帖子以及此解决方案的建议的组合:

I figured it out, it was a combination of the suggestions on this post and this solution as well:

找不到圆形ci中的com.android.tools.build:gradle:3.0.0-alpha1

我需要将google()包含在两个位置,以及将其切换到端口8082并在模拟器上启用该端口的解决方案.非常感谢您的帮助!!! =)

I needed to include google() in both locations as well as the solution of switching it to port 8082 and enabling that port on the emulator. THANK YOU ALL SO MUCH FOR YOUR HELP!!! =)

推荐答案

在类似情况下对我有帮助的步骤:

Steps that helped me in similar case:

  1. 在不同于8081的端口上运行打包程序:react-native start --port 8082 --reset-cache
  2. 在第二个命令提示符"窗口中运行命令react-native run-android --port 8082.
  3. 出现错误屏幕后,单击Ctrl + M.
  4. 单击底部的Dev Settings按钮.
  5. 单击Debug server host & port for device按钮.
  6. 编写localhost:8082并单击OK按钮.
  7. 再次运行命令react-native run-android --port 8082
  1. Running packager on port different than 8081: react-native start --port 8082 --reset-cache
  2. Running command react-native run-android --port 8082 in second Command Prompt window.
  3. After error screen appear clicking Ctrl + M.
  4. Clicking Dev Settings button at the bottom.
  5. Clicking Debug server host & port for device button.
  6. Writing localhost:8082 and clicking OK button.
  7. Again running command react-native run-android --port 8082

这篇关于无法识别JS服务器,继续构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆