browserify 返回 visitor[(override || node.type)] 不是函数

问题描述 投票:0回答:0

我正在通过命令行运行 browserify

 browserify src/crypto/Mnemonic.js -p esmify --standalone mnembundle > src/bundle/MnemonicBundle.js

但是我收到这个错误:

Error: Parsing file C:\Users\User\Documents\GitHub\AdrestusWallet\frontend-react-basic-app\src\crypto\Mnemonic.js: visitor[(override || node.type)] is not a function
    at Deps.parseDeps (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\module-deps\index.js:519:15)
    at getDeps (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\module-deps\index.js:447:44)
    at C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\module-deps\index.js:430:38
    at ConcatStream.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\concat-stream\index.js:37:43)
    at ConcatStream.emit (node:events:525:35)
    at finishMaybe (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:630:14)
    at endWritable (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:638:3)
    at Writable.end (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:594:22)
    at DuplexWrapper.onend (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_readable.js:577:10)
    at Object.onceWrapper (node:events:627:28)

这是我的整个代码脚本:

var crypto = require('crypto')
var secureRandom = require('secure-random')
var Util=require("./Util.js")

const ALGORITHM='SHA-512'
module.exports =class Mnemonic{
    #SALT_CHARS ;
    #WordList;

    #Strength
    constructor(Strength) {
        this.hash = crypto.createHash('sha256');
        this.#Strength=Strength;
        this.#SALT_CHARS = Buffer.from(['m', 'n', 'e', 'm', 'o', 'n', 'i', 'c'])
        this.#WordList=["abandon", "ability", "able", "about"];
    }


    createSeed(mnemonic,passphrase){
      if(passphrase==null){
          throw new Error("Passphrase should not be null! Please enter a valid password");
      }
      let buffer_passphrase=Buffer.from(passphrase)
      let SALT=Buffer.concat([this.#SALT_CHARS,buffer_passphrase],this.#SALT_CHARS.length+buffer_passphrase.length);
      let derivedKey=crypto.pbkdf2Sync(mnemonic, SALT, 2048, 512, ALGORITHM);
      return derivedKey.toString('hex');
    }

    create(){
        let bytes = secureRandom.randomBuffer(this.#Strength);
        let hashbits=this.hash.update(bytes).digest();
        let binaryHash = Util.bytesToBinaryAsChars(hashbits).slice(0,this.#Strength);
        let checksum=Util.charSubarray(binaryHash,0,(bytes.length/8)*8/32)
        let entropyBits = Util.bytesToBinaryAsChars(bytes).slice(0,this.#Strength);
        let concatenatedBits=entropyBits.concat(checksum);

        var mnemonicBuilder=""
        for (let index = 0; index< concatenatedBits.length/11; ++index) {
            let startIndex = index * 11;
            let endIndex = startIndex + 11;
            let wordIndexAsChars=Array(endIndex-startIndex);
            Util.arrayCopy(concatenatedBits,startIndex,wordIndexAsChars,0,wordIndexAsChars.length)
            let wordIndex=Util.binaryCharsToInt(wordIndexAsChars);
            mnemonicBuilder+=this.#WordList[wordIndex]+' ';
        }
       return mnemonicBuilder.trim().split(' ');
    }
}

任何帮助如何解决

visitor[(override || node.type)] is not a function
这是一个错误吗?

javascript node.js npm browserify
© www.soinside.com 2019 - 2024. All rights reserved.