package.json 配置
"webpack": "^5.36.2",
"webpack-cli": "^4.6.0",
"webpack-dev-server": "^3.11.2"
当webpack-cli为4以上版本时,我们启动webpack-dev-server时,按照以往经验配置如下:
"start": "webpack-dev-server"
报错如图:
需要将scripts脚本里面的webpack-dev-server 改为webpack serve --open,jiuhaole
"start": "webpack serve --open"
如果还有报错如下:
Error: getaddrinfo ENOTFOUND localhost at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:6
在hosts里面将127.0.0.1 绑定到localhost就可成功启动服务器了