npm run build失败,显示"错误:自定义关键字定义无效:data.errors应该是boolean"

bri*_*fey 7 javascript continuous-integration npm vue.js

当我尝试构建VueJS应用程序时,我看到npm出错了.我build在GitLab CI 的一个阶段看到了这个错误.我没有找到任何提及错误消息.我以前能够npm run build成功运行并且我没有对Vue应用程序代码进行任何更改,因此我不确定是什么原因导致此错误.

-  Building for production...
 ERROR  Error: custom keyword definition is invalid: data.errors should be boolean
Error: custom keyword definition is invalid: data.errors should be boolean
    at Ajv.addKeyword (/app/node_modules/ajv/lib/keyword.js:65:13)
    at module.exports (/app/node_modules/ajv-errors/index.js:10:7)
    at Object.<anonymous> (/app/node_modules/terser-webpack-plugin/node_modules/schema-utils/src/validateOptions.js:22:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! code@0.1.0 build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the code@0.1.0 build 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!     /root/.npm/_logs/2019-02-09T22_32_54_384Z-debug.log
The command '/bin/sh -c npm run build' returned a non-zero code: 1
ERROR: Job failed: exit code 1
Run Code Online (Sandbox Code Playgroud)

这是我在用于构建Vue应用程序的docker文件中的内容:

# build stage
FROM node:10.14.2-jessie as build-stage
WORKDIR /app/
COPY frontend/package.json /app/
RUN npm cache verify
RUN npm install
COPY frontend /app/
RUN npm run build
Run Code Online (Sandbox Code Playgroud)

Ori*_*ero 5

https://github.com/webpack/webpack/issues/8768

如果使用纱线

将以下内容添加到package.json

  "resolutions": {
    "ajv": "6.8.1"
  }
Run Code Online (Sandbox Code Playgroud)

然后跑 yarn install

如果您使用npm

npm uninstall ajv
npm install ajv@6.8.1
Run Code Online (Sandbox Code Playgroud)