[英]Module parse failed: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file
[英]ReactJS: Module parse failed ',,…/index.js' you may need appropriate loader to handle this file type
我更改了從create-react-app
生成的默認index.js文件位置。
這是我的目錄結構:-
|--main-project
|--client
|--components
|--pages
|--public
|--App.js
|--index.js
|--mode_modules
|--server
|--package.json
|
|-- /react small files like package-lock.json and stuff
我在node_module / react-scripts / config中對應的path.js配置
module.exports = {
dotenv: resolveApp('.env'),
appPath: resolveApp('.'),
appBuild: resolveApp('build'),
appPublic: resolveApp('public'),
appHtml: resolveApp('client/public/index.html'),
appIndexJs: resolveApp('client/index.js'),
appPackageJson: resolveApp('package.json'),
appSrc: resolveApp('src'),
yarnLockFile: resolveApp('yarn.lock'),
testsSetup: resolveApp('src/setupTests.js'),
appNodeModules: resolveApp('node_modules'),
publicUrl: getPublicUrl(resolveApp('package.json')),
servedPath: getServedPath(resolveApp('package.json')),
// These properties only exist before ejecting:
ownPath: resolveOwn('.'),
ownNodeModules: resolveOwn('node_modules'), // This is empty on npm 3
};
我已經更改了appHtml和appIndexJS路徑
如何告訴默認的jsx加載器查看這些文件?
將appSrc:resolveApp('src')
更改為appSrc:resolveApp('client')
一切都應該正常工作!
不必使用默認文件結構,您可以按照上面的討論進行配置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.