解决npm后安装react native项目中node_module的警告,请安装react-native-modalbox

时间:2019-03-30 07:15:43

标签: firebase react-native expo

现在,我正在使用本机生成一个应用程序。 几天前,我需要在我的应用中使用Modal,因此我已经安装了“ react-native-modalbox”。(https://github.com/maxs15/react-native-modalbox

但是在那之后,我得到了如下图所示的警告。

enter image description here

我没有这个意思和解决这个问题的方法。

1 个答案:

答案 0 :(得分:0)

我认为此警告只是不影响代码的警告。

这仅仅是地铁警告。

但是,如果您想摆脱这种情况,

import { YellowBox } from "react-native";
YellowBox.ignoreWarnings(["Require cycle:", "Remote debugger"]);

希望您能参考this.

OR

我引用了此link

在项目中添加一个scripts文件夹

使用以下内容创建一个stfu.js文件

const fs = require('fs');

const codeToObscure = /console.warn\([\s\S].*"Require cycle: "/;
const problemFilePath = './node_modules/metro/src/lib/polyfills/require.js';
const problemFileContent = fs.readFileSync(problemFilePath,'utf8');
fs.writeFileSync(problemFilePath,problemFileContent.replace(codeToObscure,'const noConsoleWarn = (""'),'utf8');

将以下行添加到package.json中的scripts中:"postinstall": "node ./scripts/stfu.js", 完成后,只需rm -rf node_modules && yarn重新安装所有内容,并确保这些该死的警告现在都消失了。

我希望这些方法对您有用。