代码之家  ›  专栏  ›  技术社区  ›  Nauman Tanwir

WebPACK错误:当我执行NPM启动时,我得到“无效数量的参数”错误

  •  0
  • Nauman Tanwir  · 技术社区  · 7 年前

    对webpack很陌生。

    很明显我做错了什么或者做错了什么。但那不是什么。

    在my package.json中的 scripts ,我已经定义了自己的脚本,我想为我的项目运行这些脚本。

    build ,我只是将内容从src复制到dist。

    下面是 webpack.config.js package.json

    操作系统:Windows 10

    小精灵

    {
      "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.CONT.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;
    

    enter image description here

    0 回复  |  直到 7 年前
    推荐文章