当前位置:   article > 正文

react报 Relative imports outside of src/ are not supported_which falls outside of the project src/ directory.

which falls outside of the project src/ directory. relative imports outside

报错信息: 

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 并注释即可。

  1. new ModuleScopePlugin(paths.appSrc, [
  2. paths.appPackageJson,
  3. reactRefreshRuntimeEntry,
  4. reactRefreshWebpackPluginRuntimeEntry,
  5. babelRuntimeEntry,
  6. babelRuntimeEntryHelpers,
  7. babelRuntimeRegenerator,
  8. ]),

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号