当前位置:   article > 正文

react-create-app,src引入目录外部文件冲突问题: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

使用react—create-app构建的项目,当src文件夹下文件想引用src文件夹外文件因为官方限制问题会报以下错误。

Module not found: You attempted to import ****** 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/.

解决方法:
1,项目直接eject命令,如果之前执行过了产生了webpack等文件就不用再执行。
2,将webpack.config.dev中ModuleScopePlugin命令注释掉即可。

//new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),

  • 1
  • 2

原答案出处:https://stackoverflow.com/questions/44114436/the-create-react-app-imports-restriction-outside-of-src-directory?noredirect=1

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/65920
推荐阅读
相关标签
  

闽ICP备14008679号