升级到React Native 0.60后出现此错误。
我尝试按照错误消息中的建议使用react-native unlink <dependency>
手动取消链接每个手动链接的依赖项,但问题仍然存在。
错误消息如下:
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
- react-native-admob (to unlink run: "react-native unlink react-native-admob")
- react-native-facebook-account-kit (to unlink run: "react-native unlink react-native-facebook-account-kit")
- react-native-fbsdk (to unlink run: "react-native unlink react-native-fbsdk")
- react-native-gesture-handler (to unlink run: "react-native unlink react-native-gesture-handler")
- react-native-linear-gradient (to unlink run: "react-native unlink react-native-linear-gradient")
- react-native-localization (to unlink run: "react-native unlink react-native-localization")
- react-native-restart (to unlink run: "react-native unlink react-native-restart")
- react-native-vector-icons (to unlink run: "react-native unlink react-native-vector-icons")
- react-native-webview (to unlink run: "react-native unlink react-native-webview")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
答案 0 :(得分:3)
我设法通过以下步骤使错误消失:
[
{
"index": 2,
"empId": "ammy",
"requestorId": null,
"profile": "a",
"request": "b",
"ticketId": "abc-12345",
"createdTime": "2019-07-07 18:01:15.0",
"updatedTime": "2019-07-07 18:56:26.0",
"statusurl": "www.xyz.com",
"ticketurl": "www.abc.com",
"status": "Open",
"description": "The issue is open"
}
]
<ReactTable
data={data}
columns={[
{
columns: [
{
Header: "Employee Id",
accessor: "empId"
},
{
Header: "Requestor Id",
accessor: "requestorId"
},
{
Header: "Profile",
accessor: "profile"
},
{
Header: "Request",
accessor: "request"
},
{
Header: "Ticket",
id: "link",
accessor: d => d.ticketurl,
Cell: ({ row }) => <a href={row.ticketurl}>{row.ticketid}</a>
},
{
Header: "Created Time",
accessor: "createdTime"
},
{
Header: "Updated Time",
accessor: "updatedTime"
},
{
Header: "Status",
accessor: "status"
},
{
Header: "Description",
accessor: "description"
}
]
}
]}
defaultPageSize={10}
className="-striped -highlight"
/>
答案 1 :(得分:2)
我收到此错误“ React Native CLI对本地依赖项使用自动链接,但是以下模块是手动链接的”。然后,我用这三个命令从IOS项目中删除了这三个依赖项,即react-native-gesture-handler,react-native-reanimated和react-native-vector-icons,以解决错误;
react-native unlink react-native-gesture-handler --platforms ios
react-native unlink react-native-reanimated --platforms ios
react-native unlink react-native-vector-icons --platforms ios
然后依次是$ cd ios
和ios/myproject$ pod install
然后是cd ..
然后是myproject$ npx react-native run-ios
答案 2 :(得分:1)
基本上,自动链接是对本机链接的替代。如果您在0.60之前的版本中一直在使用React Native。
但是您也可以为不受支持的库禁用自动链接
在过渡期间,某些软件包可能不支持某些平台上的自动链接。要禁用软件包的自动链接,请更新您的 react-native.config.js 的依赖项,如下所示:
// react-native.config.js
module.exports = {
dependencies: {
'some-unsupported-package': {
platforms: {
android: null, // disable Android platform, other platforms will still autolink if provided
},
},
},
};
要进一步说明,请点击以下链接:https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
答案 3 :(得分:1)
以下内容可帮助我从项目中删除node_modules
,然后运行npm install
重新安装所有模块。
答案 4 :(得分:0)
react-native-config.js
module.exports = {
dependencies: {
'react-native.config': {
platforms: {
android: null, // disable Android platform, other platforms will still autolink if provided
},
},
},
};
答案 5 :(得分:0)
我在上面看不到任何完美的答案。这些变通办法不能真正解决问题的根本原因。
这个问题困扰了我几个月,直到我今天花了一天的时间研究这个问题。该问题是由两件事引起的:
1。 Gradle文件在Android Studio中不同步。
打开Android Studio并从React Native项目中选择android目录,然后Android Studio将自动同步并构建该项目。如果没有,请手动选择“文件”->“使用Gradle文件同步文件”。 10次中有9次会遇到问题。可能是由于过时的软件包仍使用“编译”而不是“实现”引起的,或者是其他一些奇怪的Kotlin相关问题。您可以尝试以下步骤
a)将软件包更新为新版本,或手动替换所有行(从编译到实现开始)。
b)文件->使缓存无效/重新启动,然后选择无效并重新启动。
c)构建->清理项目
如果以上都不是,则Google逐一列出每个问题,并确保项目同步并成功构建。
现在,您可以尝试运行react-native run-android,并查看是否仍显示取消链接错误消息。如果仍然存在,请执行以下操作。
2。模块仍在加载
在Android Studio中,您将看到一个.idea目录。删除/.idea下的modules.xml(首先备份,以防万一)。然后进行同步并再次构建。
这应该解决自动链接错误消息。