自从我弄乱了webpack以来已经有一段时间了,现在我遇到了一些问题。当我运行'webpack --watch'或只是'webpack'时,我得到这个:
TypeError: validateSchema is not a function
这是我的webpack.config.js:
module.exports = {
output: {
filename: "static/bundle.js"
},
module: {
rules: [
{
test: /\.jsx?$/,
include: /app/,
loader: "babel-loader",
query: {
presets: ['env','react']
}
}
]
},
devtool: "eval-source-map"
};
这是我的package.json:
{
"name": "react-base",
"version": "1.0.0",
"description": "A MERN app skeleton",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/marcodarko/react-base.git"
},
"author": "Marco Cano",
"license": "ISC",
"bugs": {
"url": "https://github.com/marcodarko/react-base/issues"
},
"homepage": "https://github.com/marcodarko/react-base#readme",
"dependencies": {
"axios": "^0.18.0",
"bluebird": "^3.5.1",
"body-parser": "^1.18.3",
"express": "^4.16.3",
"method-override": "^3.0.0",
"morgan": "^1.9.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-redux": "^5.0.7",
"react-router": "^4.3.1",
"redux": "^4.0.0",
"request": "^2.87.0"
},
"devDependencies": {
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-preset-env": "^1.7.0",
"webpack": "^1.15.0",
"webpack-cli": "^3.0.8",
"webpack-command": "^0.4.1"
}
}
npm start可以正常工作并表示加载,但是我的react代码根本无法加载。 我目前正在独自寻找解决方案,但我想将其发布到社区,以查看是否有人知道我在做什么错。
答案 0 :(得分:0)
"devDependencies": {
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-preset-env": "^1.7.0",
"webpack": "1.15.0",//removed the carat sign to use exact version
"webpack-cli": "3.0.8",
"webpack-command": "0.4.1"
}
所做的更改是为了提供webpack的确切版本,因为包括克拉符号会自动将webpack解析为上述版本或更高版本,这会产生问题,因为每次生成新版本时,构建系统都会不断在webpack中进行更改已交付。这可能会给当前正在构建的应用程序带来重大更改