HookWebpackError: 在 Windows 上使用 copy-webpack-plugin 时不支持
Posted
技术标签:
【中文标题】HookWebpackError: 在 Windows 上使用 copy-webpack-plugin 时不支持【英文标题】:HookWebpackError: Not supported when copy-webpack-plugin is used on Windows 【发布时间】:2022-01-14 04:12:40 【问题描述】:每当我尝试运行 webpack 时,我都会在 Windows 10 上遇到错误,它在 macOS 上运行良好。 这是错误
[webpack-cli] HookWebpackError: Not supported
没有“CopyPlugin”它运行良好,但我想将 img 文件夹复制到 dist 文件夹中。您是否遇到过类似的问题,您是如何解决的?
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const CopyPlugin = require('copy-webpack-plugin');
const path = require("path");
module.exports =
entry: ['./src/assets/scss/app.scss', './src/assets/js/app.js'],
output:
path: path.resolve(__dirname, 'dist'),
publicPath: '/dist',
filename: 'assets/js/app.js',
,
module:
rules: [
test: /.s?css$/,
exclude: /node_modules/,
use: [
loader: MiniCssExtractPlugin.loader
,
loader: "css-loader",
options:
importLoaders: 2
,
loader: 'sass-loader'
]
],
,
resolve:
extensions: [".js", ".jsx"]
,
optimization:
minimize: true,
minimizer: [
new TerserPlugin(),
`...`,
new CssMinimizerPlugin(),
],
,
plugins: [
new MiniCssExtractPlugin(
filename: './assets/css/app.css'
),
new CopyPlugin(
patterns: [
from: "./src/assets/img", to: "assets/img"
],
),
],
devServer:
open: true,
port: 3000,
hot: true,
static:
directory: path.join(__dirname, './'),
,
;
来自 package.json
"devDependencies":
"ajv": "^7.2.4",
"babel-preset-env": "^1.7.0",
"babel-register": "^6.26.0",
"clean-css": "^5.2.2",
"copy-webpack-plugin": "^10.0.0",
"css-loader": "^6.5.1",
"css-minimizer-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^2.4.5",
"sass": "^1.44.0",
"sass-loader": "^12.3.0",
"terser-webpack-plugin": "^5.2.5",
"webpack": "^5.64.4",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.6.0"
【问题讨论】:
你用的是什么nodejs版本? 【参考方案1】:您的节点版本低于12.20,请选择其中一种方案
1.升级你的node
npm install node@12.20.0 -g
或最新的npm install node@latest -g
在 Windows 下 npm install node
可能会起作用,您应该使用 Windows Installer (.msi) 从 https://nodejs.org/en/download/ 安装最新版本
2.降低copy-webpack-plugin的版本
npm install copy-webpack-plugin@9 -D
【讨论】:
以上是关于HookWebpackError: 在 Windows 上使用 copy-webpack-plugin 时不支持的主要内容,如果未能解决你的问题,请参考以下文章
安装在移动硬盘的Win8.1系统无法初始化为出厂设置,无法初始化你的电脑,因为它正在运行windo
text 他们黑暗需要配置 - ubuntu chnage windo with scrol mous - 个人配置
安装在移动硬盘的Win8.1系统无法初始化为出厂设置,无法初始化你的电脑,因为它正在运行windo
vue 中监听窗口发生变化,触发监听事件, window.onresize && window.addEventListener('resize',fn) ,windo