我试图在我的Windows 10机器中运行我的webpack。
我在我的根文件夹中设置了webpack。
这是我的webpack.config.js:
const path = require("path");
const SRC_DIR = path.join(__dirname, "/client/src");
const DIST_DIR = path.join(__dirname, "client/dist");
module.exports = {
config: `${SRC_DIR}/index.jsx`,
output: {
filename: `bundle.js`,
path: DIST_DIR
},
module: {
rules: [
{
test: /\.jsx?$/,
include: SRC_DIR,
loader: "babel-loader",
query: {
presets: ["react", "es2015"]
}
}
]
},
mode: "development"
};
然后在我的package.json文件中:
{
"name": "rform",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"start": "node server.js",
"build": "webpack --config webpack.config.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-preset-es2015": "^6.24.1",
"webpack": "^4.12.0",
"webpack-command": "^0.2.1"
}
}
运行npm run build
后,我收到了ff错误:
ValidationError: config-loader
Options Validation Error
options['config'] is an invalid additional property
at validate (/mnt/c/xampp/htdocs/rform/node_modules/@webpack-contrib/schema-utils/dist/validate-options.js:87:15)
at validator (/mnt/c/xampp/htdocs/rform/node_modules/@webpack-contrib/schema-utils/dist/validate-options.js:118:10)
at resolve.then (/mnt/c/xampp/htdocs/rform/node_modules/@webpack-contrib/config-loader/lib/index.js:18:7)
at process._tickCallback (internal/process/next_tick.js:109:7)
at Module.runMain (module.js:607:11)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3
npm ERR! Linux 4.4.0-17134-Microsoft
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "build"
npm ERR! node v7.10.1
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! rform@1.0.0 build: `webpack --config webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the rform@1.0.0 build script 'webpack --config webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the rform package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack --config webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs rform
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls rform
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/darrenchui/.npm/_logs/2018-06-13T07_55_50_484Z-debug.log
我确保我在dist和src文件夹中运行正确的文件设置。我在配置上做错了什么?请帮忙!
答案 0 :(得分:1)
config
选项
webpack-configuration
的内容
请仔细阅读以下链接中的配置选项
https://webpack.js.org/configuration/
我想如果您在下面的选项中将config
替换为entry
module.exports = {
entry: `${SRC_DIR}/index.jsx`,
output: {
filename: `bundle.js`,
path: `DIST_DIR`
},
module: {
rules: [
{
test: /\.jsx?$/,
include: SRC_DIR,
exclude: /node_modules/,
loader: "babel-loader",
query: {
presets: ["react", "es2015"]
}
}
]
},
mode: "development"
};