我试图让react与electron一起工作,尽管我遵循了这个网站的说明:https://dev.to/mandiwise/electron-apps-made-easy-with-create-react-app-and-electron-forge-560e
和这个网站(图标):https://chasingcode.dev/blog/electron-generate-mac-windows-app-icons
每当我运行npm run make我得到这个错误
$ npm run make
> [email protected] make C:\StandaloneApps\electronforge
> react-scripts build && electron-forge make
these parameters are deprecated, see docs for addKeyword
these parameters are deprecated, see docs for addKeyword
these parameters are deprecated, see docs for addKeyword
C:\StandaloneApps\electronforge\node_modules\ajv-keywords\keywords\_formatLimit.js:63
var format = formats[date]
^
TypeError: Cannot read property 'date' of undefined
at extendFormats (C:\StandaloneApps\electronforge\node_modules\ajv-keywords\keywords\_formatLimit.js:63:25)
at defFunc (C:\StandaloneApps\electronforge\node_modules\ajv-keywords\keywords\_formatLimit.js:54:5)
at defineKeywords (C:\StandaloneApps\electronforge\node_modules\ajv-keywords\index.js:17:22)
at Object.<anonymous> (C:\StandaloneApps\electronforge\node_modules\schema-utils\dist\validate.js:64:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] make: `react-scripts build && electron-forge make`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] make script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
字符串
我不是一个谁使这个节点模块,所以我不知道发生了什么事,但在这里。
_formatLimit.js
'use strict'
var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d:\d\d)?$/i
var DATE_TIME_SEPARATOR = /t|\s/i
var COMPARE_FORMATS = {
date: compareDate,
time: compareTime,
'date-time': compareDateTime
}
var $dataMetaSchema = {
type: 'object',
required: [ '$data' ],
properties: {
$data: {
type: 'string',
anyOf: [
{ format: 'relative-json-pointer' },
{ format: 'json-pointer' }
]
}
},
additionalProperties: false
}
module.exports = function (minMax) {
var keyword = 'format' + minMax
return function defFunc(ajv) {
defFunc.definition = {
type: 'string',
inline: require('./dotjs/_formatLimit'),
statements: true,
errors: 'full',
dependencies: ['format'],
metaSchema: {
anyOf: [
{type: 'string'},
$dataMetaSchema
]
}
}
ajv.addKeyword(keyword, defFunc.definition)
ajv.addKeyword('formatExclusive' + minMax, {
dependencies: ['format' + minMax],
metaSchema: {
anyOf: [
{type: 'boolean'},
$dataMetaSchema
]
}
})
extendFormats(ajv)
return ajv
}
}
function extendFormats(ajv) {
var formats = ajv._formats
for (var name in COMPARE_FORMATS) {
var format = formats[name]
// the last condition is needed if it's RegExp from another window
if (typeof format != 'object' || format instanceof RegExp || !format.validate)
format = formats[name] = { validate: format }
if (!format.compare)
format.compare = COMPARE_FORMATS[name]
}
}
function compareDate(d1, d2) {
if (!(d1 && d2)) return
if (d1 > d2) return 1
if (d1 < d2) return -1
if (d1 === d2) return 0
}
function compareTime(t1, t2) {
if (!(t1 && t2)) return
t1 = t1.match(TIME)
t2 = t2.match(TIME)
if (!(t1 && t2)) return
t1 = t1[1] + t1[2] + t1[3] + (t1[4]||'')
t2 = t2[1] + t2[2] + t2[3] + (t2[4]||'')
if (t1 > t2) return 1
if (t1 < t2) return -1
if (t1 === t2) return 0
}
function compareDateTime(dt1, dt2) {
if (!(dt1 && dt2)) return
dt1 = dt1.split(DATE_TIME_SEPARATOR)
dt2 = dt2.split(DATE_TIME_SEPARATOR)
var res = compareDate(dt1[0], dt2[0])
if (res === undefined) return
return res || compareTime(dt1[1], dt2[1])
}
型
正如我所说的,我不是制作formatLimit.js的人,所以如果你有解决方案,请让它非常非常明显,这样我就可以修复它。
我已经尝试过的东西:
删除节点模块并再次执行npm安装
谷歌的错误,但似乎没有人有确切的错误,我有,所以我不能真正使用他们的解决方案
改了名字,还是一样的错误。
1条答案
按热度按时间5vf7fwbs1#
我在我们的Angular(12)项目中也遇到了同样的错误,在我的案例中安装了最新版本的“ajv-keywords”(^5.1.0)解决了这个问题!