Issue
I have never used node.js before, and I have been researching the answer to this question, but I have had no luck.
I am trying to allow the user to enter an input number (and honestly have no idea how to do this). Upon some research I tested a very simple input/output code:
var readline = require('readline-sync');
var term1 = readline.question("Please enter your first binary term: ");
console.log("your number : " + term1);
But when I try this I am getting the error:
module.js:550
throw err;
^
Error: Cannot find module 'readline-sync'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/<name>/eclipse-workspace/319/SE319Assignment4/binaryCalc.js:1:78)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
I was wondering if anyone can help me figure out why readline-sync cannot be read, or if there is a better way to write this simple input/output code in general! Thanks
Solution
if you don't have the dependency listed in your package.json file, try running this command from your cmd (cd into the directory where binaryCalc.js is located at):
npm install --save readline-sync
if you do have it in there, just try
npm install
Answered By - George Neto
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.