Webpack 网页包错误:当我开始npm时,我得到;无效的参数数“;错误
非常新的网页包 我显然做错了什么或做错了什么。但不知道那是什么 在mypackage.json的Webpack 网页包错误:当我开始npm时,我得到;无效的参数数“;错误,webpack,webpack-dev-server,npm-start,webpack.config.js,Webpack,Webpack Dev Server,Npm Start,Webpack.config.js,非常新的网页包 我显然做错了什么或做错了什么。但不知道那是什么 在mypackage.json的脚本下,我定义了我自己的脚本,我希望为我的项目运行这些脚本 在build中,我只是将内容从src复制到dist 下面是webpack.config.js和package.json { "name": "react-project", "version": "1.0.0", "description": "react-project", "main": "index.js", "sc
脚本下,我定义了我自己的脚本,我希望为我的项目运行这些脚本
在build
中,我只是将内容从src复制到dist
下面是webpack.config.js
和package.json
{
"name": "react-project",
"version": "1.0.0",
"description": "react-project",
"main": "index.js",
"scripts": {
"start": "npm run build",
"build": "webpack -d && xcopy src/index.html dist/index.html && webpack-dev-server --content-base src/ --hot",
"build:prod": "webpack -p && xcopy src/index.html dist/index.html"
},
"keywords": [
"react"
],
"author": "Nauman Tanwir",
"license": "ISC",
"dependencies": {
"react": "^16.4.2",
"react-dom": "^16.4.2"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"webpack": "^4.17.2",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.7"
}
}
操作系统:Windows 10
package.json
{
"name": "react-project",
"version": "1.0.0",
"description": "react-project",
"main": "index.js",
"scripts": {
"start": "npm run build",
"build": "webpack -d && xcopy src/index.html dist/index.html && webpack-dev-server --content-base src/ --hot",
"build:prod": "webpack -p && xcopy src/index.html dist/index.html"
},
"keywords": [
"react"
],
"author": "Nauman Tanwir",
"license": "ISC",
"dependencies": {
"react": "^16.4.2",
"react-dom": "^16.4.2"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"webpack": "^4.17.2",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.7"
}
}
webpack.config.js
var path = require("path");
var DIST_DIR = path.resolve(__dirname, "dist");
var SRC_DIR = path.resolve(__dirname, "src");
var config = {
entry: SRC_DIR + "/app/index.js",
output: {
path: DIST_DIR + "/app",
filename: "bundle.js",
publicPath: "/app/"
},
module: {
rules: [{
test: /\.js?/,
include: SRC_DIR,
loader: "babel-loader",
query: {
presets: ["react", "es2015", "stage-2"]
}
}]
}
};
module.exports = config;
我在packgage.json
中更改脚本
并修改我的webpack.config.js
解决了这个问题,我已经回滚了您上次的编辑:请在中找到您的解决方案,并将其作为自己的答案发布,谢谢。