最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

的WebPack错误:自定义关键字定义无效:数据错误应该是布尔

运维笔记admin18浏览0评论

的WebPack错误:自定义关键字定义无效:数据/错误应该是布尔

的WebPack错误:自定义关键字定义无效:数据/错误应该是布尔

我使用的WebPack到中捆绑两个js文件(test.js和index.js)这是test.js的样子

console.log("i'm in test.js");
export default 35;

这是index.js看起来的样子

const num = require("./test");
console.log("Successfully export the number: " + num);

这是我的package.json文件看起来像

 "scripts": {
    "dev": "webpack"
  },

 "devDependencies": {
    "webpack": "^4.29.3",
    "webpack-cli": "^3.2.3"
  }

当我运行命令“故宫运行dev的”我的两个文件都正常工作,我得到这个错误。

> [email protected] dev C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter
> webpack

C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\webpack-cli\bin\cli.js:231
                                throw err;
                                ^

Error: custom keyword definition is invalid: data/errors should be boolean
    at Ajv.addKeyword (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\ajv\lib\keyword.js:65:13)
    at module.exports (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\ajv-errors\index.js:10:7)
    at Object.<anonymous> (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\schema-utils\src\validateOptions.js:22:1)
    at Module._compile (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\schema-utils\src\index.js:7:25)
    at Module._compile (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\webpack\lib\SourceMapDevToolPlugin.js:13:25)
    at Module._compile (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\webpack\lib\WebpackOptionsApply.js:16:32)
    at Module._compile (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `webpack`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Seinfeld\AppData\Roaming\npm-cache\_logs\2019-02-10T08_30_11_517Z-debug.log````

Anyone who knows the answer please tell me.
Thanks in advance
回答如下:

它实际上是从错误本身的WebPack。您可以降级到另一个版本。

这里是Issue

If you use yarn

添加下面的package.json

  "resolutions": {
    "ajv": "6.8.1"
  }

然后运行yarn install

if you use npm

npm uninstall ajv
npm install [email protected]
发布评论

评论列表(0)

  1. 暂无评论