"$ flutter build web"抛出错误"Missing index.html"?

问题描述:

我跑步时:

$ flutter build web 

我遇到错误

Missing index.html.

Flutter应用程序正在浏览器中显示,但是在VS Code中它显示为"No Device".如何调试或解决此问题?

The flutter app is displaying in the browser, but in VS Code it reads "No Device." How can I debug, or fix this problem?

这将有助于查看Flutter Doctor的输出,但我猜您的项目未针对网络进行配置.

It would help to see the output of your flutter doctor, but I am guessing that your project is not configured for web.

如果还没有,您需要像这样切换到Flutter Beta频道:

If you haven't already, you need to switch to the flutter beta channel like so:

$ flutter channel beta
$ flutter upgrade
$ flutter config --enable-web

这时,运行 flutter doctor 应该会显示chrome可用.

At this point, running flutter doctor should show that chrome is available.

然后,切换到您的应用程序根目录,然后运行

Then, switch into your application root directory, and run

$ flutter create .

这将重建项目以支持Web.

This will rebuild the project to support web.

然后,从同一目录中,您可以运行 flutter build web

Then, from the same directory, you can run flutter build web