内部包的“找不到模块:错误:无法解析'@ theme /'”

问题描述

使用React Native(Webpack)为网络构建react-native-web项目

我在项目内的多个文件夹中都有一个package.json,以便通过import使@更加容易。

resolve的{​​{1}}文档提到了这一点

如果该文件夹包含package.json文件,则将按顺序查找resolve.mainFields配置选项中指定的字段,然后package.json中的第一个此类字段将确定文件路径。

我的Webpack文件看起来像这样

webpack.config.js

,项目目录看起来像这样,在几个文件夹中带有const path = require('path'); const appDirectory = path.resolve(__dirname,'../'); const imageLoaderConfiguration = { test: /\.(gif|jpe?g|png|svg)$/,use: { loader: 'url-loader',options: { name: '[name].[ext]' } } }; module.exports = { entry: { app: './index.android.js' },output: { filename: 'bundle.js',path: path.resolve(__dirname,'dist') },module: { rules: [ {test: /\.js$|jsx/,loader:'babel-loader',exclude: '/node_modules/'},imageLoaderConfiguration ] },resolve: { extensions: ['.tsx','.ts','.js','.json'],mainFields: ['browser','module','main'],mainFiles: ['index'],alias: {'react-native$': 'react-native-web'},modules: [path.resolve(__dirname,'src'),'node_modules'],} };

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)