gpt4 book ai didi

Node.js 错误 - AssertionError [ERR_ASSERTION] : pattern should not use global or sticky mode . .. 重新安装包后

转载 作者:行者123 更新时间:2023-12-05 01:16:14 28 4
gpt4 key购买 nike

我有两个在 v10.14.2 上运行的 node.js 项目。两者都工作正常。

然后我删除了 package.json 中的所有包并像这样重新安装它们:

$ npm install <package01> <package02> <package03> ...

安装成功。在 11.48 秒内添加了来自 155 个贡献者的 228 个包并审计了 393 个包发现了 0 个漏洞

尝试运行它时,我现在收到一条错误消息:

$ nodemon project01

错误信息:

[nodemon] starting `node project01.js`
/home/Project01/node_modules/hoek/lib/index.js:553
throw new Assert.AssertionError({
^

AssertionError [ERR_ASSERTION]: pattern should not use global or sticky mode
at new AssertionError (internal/assert.js:269:11)
at Object.exports.assert (/home/Project01/node_modules/hoek/lib/index.js:553:11)
at internals.String.regex (/home/Project01/node_modules/joi/lib/types/string/index.js:122:14)
at Object.<anonymous> (/home/Project01/helpers/routeHelpers.js:58:27)
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)
[nodemon] app crashed - waiting for file changes before starting...

第二个应用程序也是如此:

$ npm install <package01> <package02> <package03> ...

安装成功。在 10.571 秒内添加了来自 116 个贡献者的 151 个包并审计了 303 个包发现了 0 个漏洞

$ nodemon project02

错误信息:

[nodemon] starting `node project02.js`
/home/Project02/node_modules/hoek/lib/index.js:553
throw new Assert.AssertionError({
^

AssertionError [ERR_ASSERTION]: pattern should not use global or sticky mode
at new AssertionError (internal/assert.js:269:11)
at Object.exports.assert (/home/Project02/node_modules/hoek/lib/index.js:553:11)
at internals.String.regex (/home/Project02/node_modules/joi/lib/types/string/index.js:122:14)
at Object.<anonymous> (/home/Project02/helpers/routeHelpers.js:47:27)
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)
[nodemon] app crashed - waiting for file changes before starting...

我错过了什么,我需要做什么来解决这个问题?

最佳答案

当您升级到 v14 时,此错误来自 @hapi/joiobject.patternstring.regex 的正则表达式发生了重大变化。您不能再使用全局 (g) 或粘性 (y) 标志。这些标志以前被忽略,但现在被拒绝。

例如全局被忽略joi.string().regex(/^[a-z0-9_-]{1,25}$/ig)

现在必须删除全局标志joi.string().regex(/^[a-z0-9_-]{1,25}$/i)

引用 @hapi/joi 发行说明 https://github.com/hapijs/joi/issues/1615

关于Node.js 错误 - AssertionError [ERR_ASSERTION] : pattern should not use global or sticky mode . .. 重新安装包后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53866343/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com