报错信息:
You attempted to import xxx which falls outside of the project src/ directory.Relative imports outside of src/ are not supported.You can either move it inside src/, or add a symlink to it from project's node_modules/.
大概意思:
您尝试导入/Users/wen/gisspring project/smart city management/node_modules/console browserify/index。js位于项目src/目录之外。不支持src/之外的相对导入。您可以将其移动到src/中,也可以从项目的node_modules/向其添加符号链接。
原因:
就是引入了src 外的资源(js,css,img等等)
解决方案:
1. 可以 把 引入的资源放到 src里
2. 因为这个 是webpack里配置了 ModuleScopePlugin 。
webpack.config.js中配置了 new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),导致限制开发者从非src目录导入模块文件
在webpack.config.js中查找 ModuleScopePlugin 并注释即可。
new ModuleScopePlugin(paths.appSrc, [
paths.appPackageJson,
reactRefreshRuntimeEntry,
reactRefreshWebpackPluginRuntimeEntry,
babelRuntimeEntry,
babelRuntimeEntryHelpers,
babelRuntimeRegenerator,
]),