wepack4配置webpack-dev-server报错
const validateSchema = process.webpackModule.validateSchema;
^TypeError: Cannot read property 'validateSchema' of undefined
at Object.<anonymous> (E:wampwamp64wwwKaoyannode_moduleswebpack-clibinconvert-argv.js:7:46)
//webpackconfig.js
const webpack = require("webpack");
const path = require("path");
const UglifyJSPlugin = require("uglifyjs-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
module.exports = {
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
},
{
test: /\.(scss|css)$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader"
},
{
loader: "sass-loader"
}
]
}
]
},
plugins: [
new CleanWebpackPlugin(["dist"]),
new UglifyJSPlugin(),
new HtmlWebpackPlugin({ title: "kaoyan", template: "./index.html" })
],
entry: "./src/index",
output: {
filename: "[name].[chunkhash].js",
chunkFilename: "[name].[chunkhash].js",
path: path.resolve(__dirname, "dist")
}
};
{
"name": "kaoyan",
"version": "1.0.0",
"description": "kaoyan app",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --mode=development --open"
},
"author": "Renkosky",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"clean-webpack-plugin": "^0.1.19",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.10.2",
"webpack-cli": "^3.0.0",
"webpack-dev-server": "^3.1.4"
},
"dependencies": {
"css-loader": "^0.28.11",
"node-sass": "^4.9.0",
"react": "^16.4.0",
"react-dom": "^16.4.0",
"sass-loader": "^7.0.2",
"style-loader": "^0.21.0",
"uglifyjs-webpack-plugin": "^1.2.5"
}
}
我记得配置中不修改dev-server行为的话就不用添加dev-server的相关配置,但不知怎么就是报错,如果有知道的求告知,感激不尽!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从报错来看的话,是process的问题,dev-server有一个配置参数是process,可以查查api有讲解
开发环境不能使用chunkhash,你把输出文件名改一下应该就可以了