gpt4 book ai didi

webpack-dev-server 打开 localhost :8080/undefined

转载 作者:行者123 更新时间:2023-12-04 13:25:45 25 4
gpt4 key购买 nike

当我运行 $ npm run dev ( "dev": "webpack-dev-server" ) 它打开 localhost:8080/undefined 而不是 localhost:8080 或至少 localhost:8080/index.html

webpack-config.js devServer 部分:

开发服务器:{

    contentBase: path.join(__dirname, 'dist'),

compress: true,

stats: "errors-only",

hot: true,

open: true

如果我删除 URL 的/undefined 部分,即使是热模块更换,它也能正常工作,所以这不是一个大问题;只是想知道为什么会这样。

编辑:我在 MacOS 上

Edit2: npm run dev 时的控制台信息:
Project is running at http://localhost:8080/
webpack output is served from /
Content not from webpack is served from /Users/cozarkd/folders/dist
webpack: wait until bundle finished: /undefined
webpack: Compiled successfully.

最佳答案

这似乎是由错误引起的:https://github.com/webpack/webpack-dev-server/issues/960

提供了一种快速解决方法 (here):

devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
stats: "errors-only",
hot: true,
open: true,
openPage: '' // <-- this
}

关于webpack-dev-server 打开 localhost :8080/undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44924263/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com