cnpmcore
cnpmcore copied to clipboard
[SyntaxError]Unexpected token ':'
在请求接口(http://127.0.0.1:7000/-/package/0g/syncs)时报错:
{
"error": "Unexpected token ':'"
}
具体报错信息:
Error compiling schema, function code: const schema22 = scope.schema[12];const func1 = scope.func[1];const func3 = scope.func[2];return function validate19(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate19.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if(((((((data.fullname === undefined) && (missing0 = "fullname")) || ((data.tips === undefined) && (missing0 = "tips"))) || ((data.skipDependencies === undefined) && (missing0 = "skipDependencies"))) || ((data.syncDownloadData === undefined) && (missing0 = "syncDownloadData"))) || ((data.force === undefined) && (missing0 = "force"))) || ((data.forceSyncHistory === undefined) && (missing0 = "forceSyncHistory"))){validate19.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.fullname !== undefined){let data0 = data.fullname;const _errs1 = errors;if(typeof data0 !== "string"){validate19.errors = [{instancePath:instancePath+"/fullname",schemaPath:"#/properties/fullname/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(typeof {"str":"data0"} == "string" && {"str":"data"} !== undefined){data0 = {"str":"func1","prefix":"func","value":{"code":{"_items":["require(\"ajv-keywords/dist/definitions/transform\").transform",".trim",""]}},"scopePath":{"_items":[".",{"str":"func"},"[",1,"]"]}}({"str":"data0"});{"str":"data"}[{"_items":["","\"fullname\"",""]}] = data0;}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.tips !== undefined){let data1 = data.tips;const _errs3 = errors;if(typeof {"str":"data1"} == "string" && {"str":"data"} !== undefined){data1 = {"str":"func1","prefix":"func","value":{"code":{"_items":["require(\"ajv-keywords/dist/definitions/transform\").transform",".trim",""]}},"scopePath":{"_items":[".",{"str":"func"},"[",1,"]"]}}({"str":"data1"});{"str":"data"}[{"_items":["","\"tips\"",""]}] = data1;}if(errors === _errs3){if(typeof data1 === "string"){if(func3(data1) > 1024){validate19.errors = [{instancePath:instancePath+"/tips",schemaPath:"#/properties/tips/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"}];return false;}}else {validate19.errors = [{instancePath:instancePath+"/tips",schemaPath:"#/properties/tips/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.skipDependencies !== undefined){const _errs5 = errors;if(typeof data.skipDependencies !== "boolean"){validate19.errors = [{instancePath:instancePath+"/skipDependencies",schemaPath:"#/properties/skipDependencies/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.syncDownloadData !== undefined){const _errs7 = errors;if(typeof data.syncDownloadData !== "boolean"){validate19.errors = [{instancePath:instancePath+"/syncDownloadData",schemaPath:"#/properties/syncDownloadData/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.force !== undefined){const _errs9 = errors;if(typeof data.force !== "boolean"){validate19.errors = [{instancePath:instancePath+"/force",schemaPath:"#/properties/force/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.forceSyncHistory !== undefined){const _errs11 = errors;if(typeof data.forceSyncHistory !== "boolean"){validate19.errors = [{instancePath:instancePath+"/forceSyncHistory",schemaPath:"#/properties/forceSyncHistory/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.registryName !== undefined){const _errs13 = errors;if(typeof data.registryName !== "string"){validate19.errors = [{instancePath:instancePath+"/registryName",schemaPath:"#/properties/registryName/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs13 === errors;}else {var valid0 = true;}}}}}}}}}else {validate19.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate19.errors = vErrors;return errors === 0;}
2022-10-13 15:24:55,675 ERROR 12888 [-/127.0.0.1/22d3e4a0-4ac8-11ed-ac55-f98970771cdb/11.491ms PUT /npm-normalize-package-bin/sync?nodeps=false&force=true] nodejs.SyntaxError: Unexpected token ':'
at new Function (<anonymous>)
at Ajv2019.compileSchema (/Users/admin/work/cnpmcore/node_modules/egg-typebox-validate/node_modules/ajv/lib/compile/index.ts:171:26)
at Ajv2019._compileSchemaEnv (/Users/admin/work/cnpmcore/node_modules/egg-typebox-validate/node_modules/ajv/lib/core.ts:733:24)
at Ajv2019.compile (/Users/admin/work/cnpmcore/node_modules/egg-typebox-validate/node_modules/ajv/lib/core.ts:385:34)
at Ajv2019.validate (/Users/admin/work/cnpmcore/node_modules/egg-typebox-validate/node_modules/ajv/lib/core.ts:361:16)
at Object.tValidate (/Users/admin/work/cnpmcore/node_modules/egg-typebox-validate/app/extend/context.ts:6:21)
at PackageSyncController.createSyncTask (/Users/admin/work/cnpmcore/app/port/controller/PackageSyncController.ts:72:9)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async PackageSyncController.deprecatedCreateSyncTask (/Users/admin/work/cnpmcore/app/port/controller/PackageSyncController.ts:183:18)
pid: 12888
hostname: admindeMac-mini.local
怀疑和 ajv 版本有关,在项目中锁定 ajv 版本 "ajv": "8.8.2",即不会报错。 npm i 时,npm 依赖扁平管理下,顶层安装的 ajv 版本是 7.2.4,这个时候会报错。