📅  最后修改于: 2023-12-03 15:35:40.661000             🧑  作者: Mango
如果你在用 Rails 和 Webpacker 进行前端开发,你可能会遇到这个错误信息:
Webpacker::Manifest::MissingEntryError in Users#index
Webpacker can't find hello-world in /path/to/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's manifest.json file in some way.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
该错误的原因是 Webpacker 找不到相应的入口文件进行编译。这可能是由以下原因导致的:
webpack -w
或者 webpack-dev-server
,请将 compile
设置为 true
,否则 Webpacker 无法编译前端代码。为解决这个问题,你可以尝试以下步骤:
development
环境,请将 compile
设置为 true
,并运行 ./bin/webpack-dev-server
或者 ./bin/webpack -w
命令。webpack-dev-server
,尝试重新启动该服务以重新编译前端代码。config/webpacker.yml
文件中的配置是否正确,尤其是 public_output_path
是否设置正确。app/javascript/packs
文件夹下是否存在名为 hello-world.js
的入口文件,如果不存在请创建该文件。如果你在以上步骤尝试后仍然无法解决问题,可能需要进一步检查 Webpack 配置以及应用代码是否有其他问题。