This is a blockchain test. It seems that it was OK the last time I ran it. When I came to run the project today, the following error occurred. I want to know why.
import vorpal from "vorpal";
import BlockChain from "/D:/MyProject/JSProject/BlockChain/lab-01/Blockchain.js";
const blockChain = new BlockChain()
vorpal
.command('mine','mine1')
.action(function(args,callback){
const newBlock = blockChain.mine()
if(newBlock){
console.log(newBlock)
}
callback
})
console.log('welcome to BlockChain')
vorpal.exec('help')
2
Answers
Here are my Blockchain.js and myVorpal.js files.
These two files are actually in the same directory. Vorpal has indeed downloaded them and importing them should be no problem. I'm sorry that I really can't find any obvious problems. I can provide too little information.
The problem appears to be connected to how you import the
BlockChain
class in your JavaScript code. The location you provided appears to be a Windows file path (D:/MyProject/JSProject/BlockChain/lab-01/Blockchain.js
), which may cause problems when running your code with Node.js. Make sure yourBlockchain.js
file is in the same directory as your main JavaScript project, or import theBlockchain
class using a relative path.