如何允许 :8080 的 EACCESS 以便 运行 webpack 开发服务器?
How to allow EACCESS for :8080 in order to run webpack dev server?
由于我正在学习手动配置 Webpack,因此在 运行 启动脚本时遇到此错误 (EACCES: permission denied 127.0.0.1:8080)。
结果是:
× 「wds」: Error: listen EACCES: permission denied 127.0.0.1:8080
at Server.setupListenHandle [as _listen2] (net.js:1292:21)
at listenInCluster (net.js:1357:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1496:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:69:10) {
code: 'EACCES',
errno: 'EACCES',
syscall: 'listen',
address: '127.0.0.1',
port: 8080
}
i 「wdm」: asset bundle.js 362 KiB [emitted] (name: main)
runtime modules 430 bytes 3 modules
cacheable modules 333 KiB
modules by path ./node_modules/webpack-dev-server/client/ 20.9 KiB 10 modules
modules by path ./node_modules/html-entities/lib/*.js 61 KiB 5 modules
modules by path ./node_modules/url/ 37.4 KiB 3 modules
modules by path ./node_modules/querystring/*.js 4.51 KiB
./node_modules/querystring/index.js 127 bytes [built] [code generated]
./node_modules/querystring/decode.js 2.34 KiB [built] [code generated]
./node_modules/querystring/encode.js 2.04 KiB [built] [code generated]
modules by path ./node_modules/webpack/hot/*.js 1.42 KiB
./node_modules/webpack/hot/emitter.js 75 bytes [built] [code generated]
./node_modules/webpack/hot/log.js 1.34 KiB [built] [code generated]
./node_modules/webpack/hot/ sync nonrecursive ^\.\/log$ 170 bytes [built] [code generated]
webpack 5.11.0 compiled successfully in 470 ms
i 「wdm」: Compiled successfully.
虽然它说编译成功,但实际上并没有捆绑任何东西。
这是我的 package.json:
{
"name": "webpack_test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack serve --config ./webpack.config.js --mode development",
},
"keywords": [],
"license": "ISC",
"devDependencies": {
"webpack": "^5.11.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0"
},
"dependencies": {
"dotenv": "^8.2.0"
}
}
这是我的 webpack.config.js:
const path = require('path');
module.exports = {
entry: path.resolve(__dirname, './src/index.js'),
output: {
path: path.resolve(__dirname, './dist'),
filename: 'bundle.js',
},
devServer: {
contentBase: path.resolve(__dirname, './dist'),
},
};
如何在 windows 10 上允许此 EACCES?
好的,我想我找到了解决方案。我认为其他一些进程是 运行 在 8080 上,所以我将端口:3000 添加到 webpack.config.js 中的 devServer 属性 并且它现在可以工作了。我把它留在这里以防有人遇到同样的问题
由于我正在学习手动配置 Webpack,因此在 运行 启动脚本时遇到此错误 (EACCES: permission denied 127.0.0.1:8080)。 结果是:
× 「wds」: Error: listen EACCES: permission denied 127.0.0.1:8080
at Server.setupListenHandle [as _listen2] (net.js:1292:21)
at listenInCluster (net.js:1357:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1496:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:69:10) {
code: 'EACCES',
errno: 'EACCES',
syscall: 'listen',
address: '127.0.0.1',
port: 8080
}
i 「wdm」: asset bundle.js 362 KiB [emitted] (name: main)
runtime modules 430 bytes 3 modules
cacheable modules 333 KiB
modules by path ./node_modules/webpack-dev-server/client/ 20.9 KiB 10 modules
modules by path ./node_modules/html-entities/lib/*.js 61 KiB 5 modules
modules by path ./node_modules/url/ 37.4 KiB 3 modules
modules by path ./node_modules/querystring/*.js 4.51 KiB
./node_modules/querystring/index.js 127 bytes [built] [code generated]
./node_modules/querystring/decode.js 2.34 KiB [built] [code generated]
./node_modules/querystring/encode.js 2.04 KiB [built] [code generated]
modules by path ./node_modules/webpack/hot/*.js 1.42 KiB
./node_modules/webpack/hot/emitter.js 75 bytes [built] [code generated]
./node_modules/webpack/hot/log.js 1.34 KiB [built] [code generated]
./node_modules/webpack/hot/ sync nonrecursive ^\.\/log$ 170 bytes [built] [code generated]
webpack 5.11.0 compiled successfully in 470 ms
i 「wdm」: Compiled successfully.
虽然它说编译成功,但实际上并没有捆绑任何东西。 这是我的 package.json:
{
"name": "webpack_test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack serve --config ./webpack.config.js --mode development",
},
"keywords": [],
"license": "ISC",
"devDependencies": {
"webpack": "^5.11.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0"
},
"dependencies": {
"dotenv": "^8.2.0"
}
}
这是我的 webpack.config.js:
const path = require('path');
module.exports = {
entry: path.resolve(__dirname, './src/index.js'),
output: {
path: path.resolve(__dirname, './dist'),
filename: 'bundle.js',
},
devServer: {
contentBase: path.resolve(__dirname, './dist'),
},
};
如何在 windows 10 上允许此 EACCES?
好的,我想我找到了解决方案。我认为其他一些进程是 运行 在 8080 上,所以我将端口:3000 添加到 webpack.config.js 中的 devServer 属性 并且它现在可以工作了。我把它留在这里以防有人遇到同样的问题