我有一个monorepo与react-native for mobile和react for web。当我使用"react-app-rewired build“时,我得到了以下错误:
node_modules/@react-navigation/core/lib/module/getStateFromPath.js
Attempted import error: 'parse' is not exported from 'query-string' (imported as 'queryString').很明显,导入/导出出了问题,但"start“运行正常,一切都很正常。这只会在“构建”时发生。我使用"customize-cra“去掉ModuleScopePlugin,这样我就可以在src外部导入。
const { removeModuleScopePlugin, override, babelInclude, addBabelPlugins } = require("customize-cra");
const path = require("path");
module.exports = override(
removeModuleScopePlugin(), // (1)
babelInclude([
path.resolve("src"),
path.resolve("../components/src"), // (2)
path.resolve('../../node_modules'),
]),
addBabelPlugins([require.resolve('babel-plugin-react-native-web')])
);这是我的config-overrides.js。我的tsconfig没有改变,它与cra附带的一样。如果需要任何额外的信息,我会补充的。谢谢!
发布于 2021-07-11 00:05:57
我在使用react-app-rewired时也遇到了同样的问题。
您可以尝试使用craco覆盖您的webpack配置。切换到craco以某种方式消除了我的这个错误。
https://stackoverflow.com/questions/67380681
复制相似问题