Every time I run the npm run dev
command in Vue.js, a new port is automatically selected for the development build. It seems to ignore the port specified in the config/index.js
file.
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
Although I understand the comment about port selection, I have also tried changing the port in the build/webpack.dev.conf.js
file
devServer: {
clientLogLevel: 'warning',
historyApiFallback: {
rewrites: [
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
],
},
hot: true,
contentBase: false,
compress: true,
host: HOST || config.dev.host,
port: 8080,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true,
watchOptions: {
poll: config.dev.poll,
}
},
Unfortunately, this change did not resolve the issue. I need my vue app to always listen on a specific port that I specify. Any guidance on how to achieve this would be greatly appreciated.
I have already searched for solutions but have not found anything that works for me. Related question