模块无法正常工作

时间:2018-07-14 19:33:27

标签: javascript module

我有两页:

blockchain.js:     函数Blockchain(){         this.chain = [];         this.newTransactions = [];     }     Blockchain.prototype.createNewBlock = function(nonce,previousHash,hash){         const newBlock = {             事务:this.newTransactions,             随机数:随机数,             哈希:哈希,             previousHash:PreviousHash         };         this.newTransactions = [];         this.chain.push(newBlock);

    return newBlock ;
}
module.exports = Blockchain;

test.js:

const Blockchain = require('./blockchain') ;
const bitcoin = new Blockchain() ;

bitcoin.createNewBlock(23833,'asjakdja' , 'asdasdasdadasd') ;
console.log(bitcoin);

当我使用node test.js时,会产生以下错误:

Error: Cannot find module 'E:\wamp\www\blockchain\test'
  at Function.Module._resolveFilename (module.js:527:15)
  at Function.Module._load (module.js:453:25)
  at Function.Module.runMain (module.js:665:10)
  at startup (bootstrap_node.js:201:16)
  at bootstrap_node.js:626:3

我该如何解决?

0 个答案:

没有答案