ymt*_*mtx 3 javascript plugins uri webpack npm-run
错误:
\nHtml Webpack 插件:\n错误: webpack://webpack/data:text/javascript, webpack_public_path _= webpack_base_uri =_htmlWebpackPl uginPublicPath;?:2\n webpack_require .p = webpack_base_uri = htmlWebpackPluginPublicPath;\n^
\nReferenceError:webpack_base_uri未定义
\njavascript, webpack_public_path _= webpack_base_uri = htmlWebpackPluginPublicPath;?:2 eval\nwebpack://webpack/data:text/javascript, webpack_public_path = webpack_base_uri =_htmlWebpackPluginP ublicPath;?:2:46
\nindex.html:30 Object.data:text/javascript, webpack_public_path = webpack_base_uri = htmlWebpackPlug inPublicPath;\nC:/Users/Ymtx/Desktop/vue/webpack/src/index.html:30:1
\nindex.html:53 webpack_require \nC:/Users/Ymtx/Desktop/vue/webpack/src/index.html:53:41
\n我不知道为什么会发生这种情况,我读过很多博客,但很少有关于它的博客。我确实想处理它。请帮助我。
\nvar webpack = require('webpack');\n\nconst path = require('path');\n\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\n\nconst htmlPlugin = new HtmlWebpackPlugin({\n template:'./src/index.html',\n filename:'index.html',\n})\n\nmodule.exports = {\nmode:"development",\n\nentry:path.join(__dirname,'./src/index.js'),\noutput:{\n path:path.join(__dirname,'./dist'),\n \n filename:'bundle.js' \n },\n plugins:[htmlPlugin]\nRun Code Online (Sandbox Code Playgroud)\n}
\n{\n "name": "webpack",\n "version": "1.0.0",\n "description": "",\n "main": "index.js",\n "scripts": {\n "test": "echo \\"Error: no test specified\\" && exit 1",\n "dev": "webpack-dev-server --open --host --127.0.0.1 --port 8888"\n },\n "keywords": [],\n "author": "",\n "license": "ISC",\n "dependencies": {\n "jquery": "^3.6.0"\n },\n "devDependencies": {\n "css-loader": "^5.2.4",\n "html-webpack-plugin": "^5.3.1",\n "style-loader": "^2.0.0",\n "vue": "^2.6.12",\n "webpack": "^4.46.0",\n "webpack-cli": "^3.3.12",\n "webpack-dev-server": "^3.1.14"\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n
小智 6
此问题是因为html-webpack-plugin它当前要求对等点"webpack": "^5.20.0"
但已在5.21.0__webpack_base_uri__中添加。
https://webpack.js.org/api/module-variables/#__webpack_base_uri__-webpack-specific
要快速修复,您可以将webpack.config.js放入顶部
__webpack_base_uri__ = 'http://localhost:8081';
注意:该端口是您的开发服务器将被提供的位置
| 归档时间: |
|
| 查看次数: |
2091 次 |
| 最近记录: |