question:
Tip: built files are meant to be served over an HTTP server. Opening over file:// won't work.
explain:
npm run dev is the development environment, npm run build is the production environment. After completing the code and testing in the development environment, the code is generated using the production environment. After executing the npm run build command, the dist directory will be generated, which contains the and static folders.
When npm run build, Built files are meant to be served over an HTTP server. Opening over file:// won't work., In the default configuration of vue-cli, change assetsPublicPath: '/' to assetsPublicPath: './', the files in the dist folder must be placed in the root directory of the server. If you want to open locally, you can execute the following command after npm run build is completed:
npm install -g http-server // This command only needs to be executed once, After installation, There is no need to reinstall it in the future.
The above article solves the problem that the Vue-cli npm run build production environment cannot be opened locally is all the content I share with you. I hope you can give you a reference and I hope you can support me more.