React webpack 开启 gzip 压缩 报错 ValidationError: Compression Plugin Invalid Options

报错内容:

$ npm run build

> [email protected] build D:\_DATA_\webStormProject\nuistoj
> node scripts/build.js

D:\_DATA_\webStormProject\nuistoj\node_modules\schema-utils\src\validateOptions.js:32
    throw new ValidationError(ajv.errors, name);
    ^

ValidationError: Compression Plugin Invalid Options

options should NOT have additional properties

    at validateOptions (D:\_DATA_\webStormProject\nuistoj\node_modules\schema-utils\src\validateOptions.js:32:11)
    at new CompressionPlugin (D:\_DATA_\webStormProject\nuistoj\node_modules\compression-webpack-plugin\dist\index.js:55:31)
    at module.exports (D:\_DATA_\webStormProject\nuistoj\config\webpack.config.js:478:7)
    at Object. (D:\_DATA_\webStormProject\nuistoj\scripts\build.js:52:16)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

解决办法:
将package.json中的"compression-webpack-plugin": "^2.0.0", 版本降至 "compression-webpack-plugin": "^1.1.11", 重新安装"compression-webpack-plugin"之后在npm run build即可。

你可能感兴趣的:(React系列)