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.
- npm ERR code ELIFECYCLE [How to Solve]
- [Solved] Vue Error: Module build failed: Error: No PostCSS Config found in
- After Vue is packaged to the server, the static resource path reports an error
- Vue-cli2 sub environment packaging
- [Solved] Vue project deploys nginx to refresh the interface 404 Error
- OTS parsing error: invalid version tag [How to Solve]
- [Solved] Vue calls style loader error: Module build failed: CssSyntaxError
- How to Solve electron import page Error
- [Solved] Vue Error: Module build failed Error Node Sass version 6.0.1 is incompatible with ^4.0.0.
- proxy error: could not proxy request [How to Solve]
- How to Solve Nodejs error: cannot find module ‘. /application’
- Cannot read property ‘isFile‘ of undefined [How to Solve]
- Error: Cannot find module ‘./application‘ [How to Solve]
- Vue project change directory run error:Multiple assets emit different content to the same filename index.html
- [Solved] Prittier format code error: JSON Error in…
- Module build failed: Error: Couldn’t find preset “es2015” relative to directory
- [Solved] Error: ENOENT: no such file or directory, scandir ‘..\node_modules\node-sass\vendor‘
- [Solved] Vue Error: Syntax Error: TypeError: Cannot set properties of undefined (setting ‘XXX’)
- [Solved] SyntaxError: Cannot use import statement outside a module