我有两页:
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
我该如何解决?