I wrote the following javascript program on VSCode:
try{
const prompt = require("prompt-sync")({sigint: true})
}catch(err){
``console.log(err)
}
I am getting th efollowing error message:
Error: Cannot find module 'prompt-sync'
Following is my code:
Require stack:
- d:\Varsity Tutor_Lecture\Javascript\programs\posNegZero.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (d:\Varsity Tutor_Lecture\Javascript\programs\posNegZero.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'd:\Varsity Tutor_Lecture\Javascript\programs\posNegZero.js' ]
}
d:\Varsity Tutor_Lecture\Javascript\programs\posNegZero.js:6
let val1 = prompt("Input a Number")
^
ReferenceError: prompt is not defined
at Object.<anonymous> (d:\Varsity Tutor_Lecture\Javascript\programs\posNegZero.js:6:12)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49
Node.js v20.11.1
[Done] exited with code=1 in 0.101 seconds
I used the following command to install it:
C:\Users\zulfi>npm install prompt-sync
added 3 packages, and audited 4 packages in 859ms
found 0 vulnerabilities
C:\Users\zulfi>
Somebody, please guide me what is the problem.
Zulfi.