当我尝试构建VueJS应用程序时看到npm错误。我在GitLab CI的build
阶段内看到此错误。我没有找到关于错误消息的任何提及。以前,我已经能够成功运行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
这是我用于构建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
答案 0 :(得分:4)
https://github.com/webpack/webpack/issues/8768
添加到以下package.json
"resolutions": {
"ajv": "6.8.1"
}
然后运行yarn install
npm uninstall ajv
npm install ajv@6.8.1
答案 1 :(得分:0)
在节点模块中,我将ajv文件夹重命名为ajv1。现在,我将其他版本的ajv文件夹的较旧版本复制到了node-modules文件夹中。奏效了。
答案 2 :(得分:0)
快速修复:
转到node_modules文件夹中的 ajv 依赖项:
node_modules / ajv / lib / keyword.js
注释第64和65行:
if (!validateDefinition(definition))
throw new Error('custom keyword definition is invalid: ' + this.errorsText(validateDefinition.errors));
它应该没有副作用。