After NPM run build is executed, a dist folder will be generated, index.html will be opened, and an error will be reported on the console
As shown in the figure below:
This is because the correct path cannot be found, resulting in an error.
Solution:
1. In the root directory, create a new vue.config.js file. Of course, if any, ignore this item;
2. In vue.config.js, change publicpath: “/” to Publicpath: “. /”, then repackage and NPM run build.
publicPath: “/” =====>>>>>>>> publicPath: “./”
For the location of writing, you can refer to the following code:
module.exports = {
devServer: {
port: 8080,
open: true
},
lintOnSave: false,
publicPath: "./",
outputDir: "dist",
assetsDir: "static",//Set the directory where the static resources (js, css, img, fonts) generated by the package will be placed.
indexPath: 'index.html'//Used to set the storage location of the index.html file generated by the package
}
Read More:
- “Failed to load resource: net::ERR_FILE_NOT_FOUND” error. The project created by vue-cli 3.0 can run under dev, and an error is reported after packaging, and the page is blank.
- Vue item packaging error: errno 134 [How to Solve]
- [Solved] Failed to load resource: net::ERR_FILE_NOT_FOUND
- After Vue is packaged to the server, the static resource path reports an error
- [Solved] arco design vite-plugin-style-import Load menu-item error: Internal server error…
- [Solved] vue3vite Error: Failed to resolve import “@vue/server-renderer from “src\App.vue“. Does the file exist
- [Solved] Vue item error: Regeneratorruntime is not defined
- Solution to some map files in JS folder after Vue packaging (remove the map. JS file)
- [Solved] Failed to load plugin ‘vue‘ declared in ‘.eslintrc.js‘: createRequire is not a function
- Vue3.0 error: Failed to resolve component el-form-item (el element to be unable to be displayed)
- [Solved] Vue Error: Module build failed: Error: No PostCSS Config found in
- Vue displays 404 and 500 interfaces according to HTTP response status
- [Solved] Uncaught (in promise) DOMException: Failed to load because no supported source was found.
- [Solved] Vue Import swiper.css Error: Module not found…
- [Solved] Vue Error: Error: Rule can only have one resource source (provided resource and test + include + ex
- [Solved] Vue E-Charts Error: These dependencies were not found:
- Vue Project Error: Expected indentation of 2 spaces but found 4,Newline required at end of file but not found
- [Solved] Vue Project Error: This relative module was not found
- [Solved] Vite Error: Failed to load module script: Expected a JavaScript module script but the server…
- Vue Start Error: This relative module was not found: