react-native 转换错误找不到预设 "react-native"
react-native transform error couldn't find preset "react-native"
当 运行 处于开发模式的 react-native 应用程序启动 npm 服务器后。当应用程序请求捆绑包时,它给出了这个错误,
The development server returned response error code:500
URL: http://192.168.1.55:8081/index.android.bundle?platform=android&
dev=true&hot=false&minify=false
Body:
{"message":"TransformError:/var/www/html/test_projects/test/index.android.js:
Couldn't find preset \"react-native\" relative to directory
\"/var/www/html/test_projects\"","type":"TransofrmError","errors":[{}]}
此错误是由于 React 和 react-native 版本不兼容造成的。
要使其正常工作,您必须使用以下方法安装正确的 React 和 react-native 版本。
例如
npm install --force react@15.2.0
npm install --force react-native@0.28.0
检查 package.json 文件是否 react-native 安装正确。您还可以在项目的根目录中创建 .babelrc 文件,内容如下:
{
"presets": ["react-native"]
}
当 运行 处于开发模式的 react-native 应用程序启动 npm 服务器后。当应用程序请求捆绑包时,它给出了这个错误,
The development server returned response error code:500
URL: http://192.168.1.55:8081/index.android.bundle?platform=android&
dev=true&hot=false&minify=false
Body:
{"message":"TransformError:/var/www/html/test_projects/test/index.android.js:
Couldn't find preset \"react-native\" relative to directory
\"/var/www/html/test_projects\"","type":"TransofrmError","errors":[{}]}
此错误是由于 React 和 react-native 版本不兼容造成的。 要使其正常工作,您必须使用以下方法安装正确的 React 和 react-native 版本。
例如
npm install --force react@15.2.0
npm install --force react-native@0.28.0
检查 package.json 文件是否 react-native 安装正确。您还可以在项目的根目录中创建 .babelrc 文件,内容如下:
{
"presets": ["react-native"]
}