我和webpack·克莱有个麻烦
我要运行这个档案webpack:
const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/app.js',
output: {
path: path.resolve(__dirname , '..dist'),
filename: 'bundle.js'
},
plugins = [
new HtmlWebPackPlugin({
template: './src/index.hbs'
})
]
}西斯特姆的档案就像:
- package-lock.json
- packege.json
- webpack.config.js这是我的package.son:
{
"name": "webpack-workflow",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"autoprefixer": "^10.2.5",
"css-loader": "^5.2.0",
"file-loader": "^6.2.0",
"handlebars": "^4.7.7",
"handlebars-loader": "^1.7.1",
"html-webpack-plugin": "^5.3.1",
"image-webpack-loader": "^7.0.1",
"mini-css-extract-plugin": "^1.4.1",
"node-sass": "^5.0.0",
"postcss-loader": "^5.2.0",
"rimraf": "^3.0.2",
"sass-loader": "^11.0.1",
"webpack": "^5.31.0",
"webpack-cli": "^4.6.0",
"webpack-dev-server": "^3.11.2"
}
}因此,从终端I类型:npx webpack --config webpack.config.js
这个错误正在显示。
[webpack-cli] Failed to load 'C:\Users\Gerso\Documents\WebPack\webpack-workflow\webpack.config.js' config
[webpack-cli] Error: Cannot find module 'C:\Users\Gerso\Documents\WebPack\webpack-workflow\webpack.config.js'
Require stack:
- C:\Users\Gerso\Documents\WebPack\webpack-workflow\node_modules\webpack-cli\lib\webpack-cli.js
- C:\Users\Gerso\Documents\WebPack\webpack-workflow\node_modules\webpack-cli\lib\bootstrap.js
- C:\Users\Gerso\Documents\WebPack\webpack-workflow\node_modules\webpack-cli\bin\cli.js
- C:\Users\Gerso\Documents\WebPack\webpack-workflow\node_modules\webpack\bin\webpack.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (C:\Users\Gerso\Documents\WebPack\webpack-workflow\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at loadConfig (C:\Users\Gerso\Documents\WebPack\webpack-workflow\node_modules\webpack-cli\lib\webpack-cli.js:1322:31)
at C:\Users\Gerso\Documents\WebPack\webpack-workflow\node_modules\webpack-cli\lib\webpack-cli.js:1409:74
at Array.map (<anonymous>)
at WebpackCLI.resolveConfig (C:\Users\Gerso\Documents\WebPack\webpack-workflow\node_modules\webpack-cli\lib\webpack-cli.js:140 at WebpackCLI.createCompiler (C:\Users\Gerso\Documents\WebPack\webpack-workflow\node_modules\webpack-cli\lib\webpack-cli.js:1839:33)
at WebpackCLI.buildCommand (C:\Users\Gerso\Documents\WebPack\webpack-workflow\node_modules\webpack-cli\lib\webpack-cli.js:1954:31) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Gerso\\Documents\\WebPack\\webpack-workflow\\node_modules\\webpack-cli\\lib\\webpack-cli.js',
'C:\\Users\\Gerso\\Documents\\WebPack\\webpack-workflow\\node_modules\\webpack-cli\\lib\\bootstrap.js',
'C:\\Users\\Gerso\\Documents\\WebPack\\webpack-workflow\\node_modules\\webpack-cli\\bin\\cli.js',
'C:\\Users\\Gerso\\Documents\\WebPack\\webpack-workflow\\node_modules\\webpack\\bin\\webpack.js'
]
}
PS C:\Users\Gerso\Documents\WebPack\webpack-workflow> npx webpack --config webpack.config.js
[webpack-cli] Failed to load 'C:\Users\Gerso\Documents\WebPack\webpack-workflow\webpack.config.js' config
[webpack-cli] C:\Users\Gerso\Documents\WebPack\webpack-workflow\webpack.config.js:10
plugins = [
^^^^^^^^^^^我做错什么了??
发布于 2021-07-07 15:41:36
在你的webpack.config.js里
plugins = [
应该是
plugins: [
要验证配置,可以运行:
webpack configtest webpack.config.jshttps://stackoverflow.com/questions/67009593
复制相似问题