使用react-create-app构建的项目,当src文件夹下文件想引用src文件夹外文件由于官方限制问题会报如下错误。
node
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/.react
解决方法:1,项目直接eject命令,若是以前执行过了产生了webpack等文件就不用再执行。webpack
2,将webpack.config.dev中ModuleScopePlugin命令注释掉便可。web
//new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),