在node.js中,
导入两个包(node-7z和xml2json)时,我都遇到问题,
我有一个没有人调用的功能(“虚拟”),
import { extractFull } from 'node-7z'
const xml2json = require('xml2json');
function dummy(){
const myStream = extractFull('./zip/myfile.7z', './unzipped/')
}
我收到以下错误
C:\projects\nodeTests\node_modules\joi\lib\types\object\index.js:445
source-map-support.js:445
Hoek.assert(isRegExp || pattern instanceof Any, 'pattern must be a regex or schema');
^
AssertionError [ERR_ASSERTION]: pattern must be a regex or schema
source-map-support.js:448
at internals.Object.pattern (C:\projects\nodeTests\node_modules\joi\lib\types\object\index.js:445:14)
at Object.internals.root (C:\projects\nodeTests\node_modules\joi\lib\index.js:432:34)
at Object.<anonymous> (C:\projects\nodeTests\node_modules\joi\lib\index.js:447:28)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\projects\nodeTests\node_modules\xml2json\lib\xml2json.js:3:11)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
*如果我注释“虚拟”函数中的代码,则不会收到任何错误
*如果我注释了要求“ xml2json”这一行,则不会出现任何错误
为什么会有这个问题,为什么如果没有人调用此函数,“ dummy”函数中的代码会对我产生什么影响?
谢谢
答案 0 :(得分:0)
https://github.com/quentinrossetti/node-7z 根据此链接,您应该使用例如extractFull函数传递对象
import Seven from 'node-7z'
const myStream = Seven.extractFull('./archive.7z', './output/dir/', {
$progress: true
});