以前有人见过这个问题吗?帮帮我。
\n文本中的错误输出:
\nyarn run v1.17.3\n\n$ webpack-dev-server webpack --config ./webpack.dev.config.js --mode development\ni \xef\xbd\xa2wds\xef\xbd\xa3: Project is running at http://localhost:9000/\ni \xef\xbd\xa2wds\xef\xbd\xa3: webpack output is served from /\ni \xef\xbd\xa2wds\xef\xbd\xa3: Content not from webpack is served from E:\\demo\\webpack-demo\ni \xef\xbd\xa2wdm\xef\xbd\xa3: wait until bundle finished: /\n\xc3\x97 \xef\xbd\xa2wdm\xef\xbd\xa3: Error: Library name must be a string or string array\n at AssignLibraryPlugin.parseOptions (E:\\demo\\webpack-demo\\node_modules\\webpack\\lib\\library\\AssignLibraryPlugin.js:110:11)\n at AssignLibraryPlugin._parseOptionsCached (E:\\demo\\webpack-demo\\node_modules\\webpack\\lib\\library\\AbstractLibraryPlugin.js:120:23)\n at compilation.hooks.finishModules.tap (E:\\demo\\webpack-demo\\node_modules\\webpack\\lib\\library\\AbstractLibraryPlugin.js:60:27)\n at Hook.eval [as callAsync] (eval at create (E:\\demo\\webpack-demo\\node_modules\\webpack\\node_modules\\tapable\\lib\\HookCodeFactory.js:33:10), <anonymous>:18:1)\n at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (E:\\demo\\webpack-demo\\node_modules\\webpack\\node_modules\\tapable\\lib\\Hook.js:18:14)\n at Compilation.finish (E:\\demo\\webpack-demo\\node_modules\\webpack\\lib\\Compilation.js:1695:28)\n at process.nextTick (E:\\demo\\webpack-demo\\node_modules\\webpack\\lib\\Compiler.js:976:19)\n at process._tickCallback (internal/process/next_tick.js:61:11)\ni \xef\xbd\xa2wdm\xef\xbd\xa3: wait until bundle finished: /\ni \xef\xbd\xa2wdm\xef\xbd\xa3: wait until bundle finished: /\ni \xef\xbd\xa2wdm\xef\xbd\xa3: wait until bundle finished: /\nRun Code Online (Sandbox Code Playgroud)\n我的 package.json 文件的内容:
\n{\n "name": "exercise",\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 webpack --config ./webpack.dev.config.js --mode development"\n },\n "keywords": [],\n "author": "",\n "license": "ISC",\n "dependencies": {\n "babel-loader": "^8.1.0",\n "core-decorators": "^0.20.0",\n "html-webpack-plugin": "^4.3.0",\n "webpack": "^5.1.3",\n "webpack-dev-server": "^3.11.0"\n },\n "devDependencies": {\n "@babel/core": "^7.12.3",\n "@babel/preset-env": "^7.12.1",\n "fs": "^0.0.1-security",\n "module": "^1.2.5",\n "webpack-cli": "3.3.12",\n "webpack-node-externals": "^2.5.2"\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n这是我的配置:
\nconst HtmlWebpackPlugin = require('html-webpack-plugin')\nconst path = require('path')\nconst nodeExternals = require("webpack-node-externals");\nmodule.exports = {\n entry: './src/index.js',\n target: 'web',\n mode: "production",\n output: {\n path: path.resolve(__dirname, 'dist'),\n filename: 'bundle.js',\n libraryTarget: "var"\n },\n externals: [nodeExternals()],\n // externals: {\n // "child_process": "require('child_process')",\n // "fs": "require('fs')",\n // "path": "require('path')"\n // },\n module: {\n rules: [{\n test: /\\.js?$/,\n use: {\n loader: 'babel-loader',\n options: {\n presets: ['@babel/preset-env']\n }\n }\n }]\n },\n plugins: [\n new HtmlWebpackPlugin({\n template: './index.html'\n })\n ],\n devServer: {\n open: true,\n port: 9000\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n这是我的第一个 StackOverflow 问题,跪求大家看一下!
\n从 webpack 中删除以下行(未使用的语句):
libraryTarget: "var"
Run Code Online (Sandbox Code Playgroud)
似乎是一个悬而未决的问题:
https://github.com/webpack/webpack/issues/11632
| 归档时间: |
|
| 查看次数: |
2024 次 |
| 最近记录: |