javascript - 我该如何解决这个错误?错误:找不到模块
问题描述
我有两页:
区块链.js:
function Blockchain() {
this.chain = [] ;
this.newTransactions = [] ;
}
Blockchain.prototype.createNewBlock = function (nonce,previousHash,hash) {
const newBlock = {
tranactions : this.newTransactions,
nonce : nonce ,
hash : hash ,
previousHash : previousHash
};
this.newTransactions = [] ;
this.chain.push(newBlock);
return newBlock ;
}
module.exports = Blockchain;
测试.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
我该如何解决这个问题?
解决方案
推荐阅读
- java - Android studio Location Manager 问题,不知道如何解决
- java - 我应该如何根据分布式服务器中的定制字段为对象组生成唯一的组 ID?
- javascript - 复制 d3.js 图
- javascript - 如何从 Spotify Player JS 库中访问音频功能
- windows - 在 Windows 上链接 CUDA 时如何强制 CMake 使用响应文件?
- node.js - 无法下载 node-sqlite3@4.2.0 - node-pre-gyp 错误尝试下载(403)访问被拒绝 - node.js
- firebase - 带有 BigQuery 的 Angular10,拒绝访问:BigQuery BigQuery:获取驱动器凭据时权限被拒绝
- android - Json 服务器正在运行但未为反应本机应用程序获取数据
- sql - “自联接”时如何从SQL中的多个表中选择*?
- apache-kafka - KStreams 加入计算