在成功构建的 webpack 包上运行“npx webpack 服务器”,发生错误时的输出并不能告诉我太多信息(错误:“错误标签”位于 webpack 开发服务器代码深处),您在哪里可以看到更多信息/细节?这是输出:
npx webpack 服务
(node:31820) [DEP_WEBPACK_DEV_SERVER_HTTPS] DeprecationWarning: 'https' option is deprecated. Please use the 'server' option.
(Use `node --trace-deprecation ...` to show where the warning was created)
<i> [webpack-dev-server] SSL certificate: C:\Code\pl-security-audit-hub\PrecisionLender.SecurityAuditHub.API\ClientApp\node_modules\.cache\webpack-dev-server\server.pem
<w> [webpack-dev-server] "hot: true" automatically applies HMR plugin, you don't have to add it manually to your webpack configuration.
<i> [webpack-dev-server] [HPM] Proxy created: ** -> https://localhost:5510
[webpack-cli] Error: wrong tag
at Object.createSecureContext (_tls_common.js:271:19)
at Server.setSecureContext (_tls_wrap.js:1331:27)
at Server (_tls_wrap.js:1186:8)
at new Server (https.js:70:3)
at Object.createServer (https.js:106:10)
at Server.createServer (C:\Code\pl-security-audit-hub\PrecisionLender.SecurityAuditHub.API\ClientApp\node_modules\webpack-dev-server\lib\Server.js:1606:53)
at Server.initialize (C:\Code\pl-security-audit-hub\PrecisionLender.SecurityAuditHub.API\ClientApp\node_modules\webpack-dev-server\lib\Server.js:1165:10)
at Server.start (C:\Code\pl-security-audit-hub\PrecisionLender.SecurityAuditHub.API\ClientApp\node_modules\webpack-dev-server\lib\Server.js:2177:16)
at async Command.<anonymous> (C:\Code\pl-security-audit-hub\PrecisionLender.SecurityAuditHub.API\ClientApp\node_modules\@webpack-cli\serve\lib\index.js:242:25)
at async Promise.all (index 1)
请参阅 https://webpack.js.org/configuration/dev-server/#devserverhttps。 此选项已弃用,取而代之的是 devServer.server 选项。
更改本地 webpack 配置:
devServer: {
...,
https: {
cert: ...,
key: ...,
},
},
进入:
devServer {
...,
server: {
type: 'https',
options: {
cert: ...,
key: ...,
},
},
},