当我尝试建立一个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! [email protected] build: `vue-cli-service build`
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.
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我搬运工文件:
# 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
https://github.com/webpack/webpack/issues/8768
添加下面的package.json
"resolutions": {
"ajv": "6.8.1"
}
然后运行yarn install
npm uninstall ajv
npm install [email protected]
在节点模块我改名ajv文件夹ajv1。现在,我从其他安装复制旧版本ajv夹到节点模块文件夹。有效。
快速解决:
转到您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));
它应该工作没有副作用。