How do I configure node modules search paths (for require()) in Code Runner for Visual Studio Code?

Viewed 32

I have recently started Javascript course & I configured my Visual studio code to run js.

Below is the code which I wrote

const prompt = require('prompt-sync')();
var fname = prompt("First name please :");
var lname = prompt("last name please :");
console.log("Your name is ",fname,lname);

I configured my VS code by installing Code Runner and also executing command npm install prompt-sync , however my code is throwing below list of long errors.

enter image description here

However if I try to run same code via cmd, it runs fine

enter image description here

Below are my npm and nodejs version enter image description here

Can anyone please let me know what am I doing wrong?

Note:- I am storing and saving all my js files in a folder on local disk D

1 Answers

Solution

cd d:\Source-code\JavaScript
npm init -y
npm i

changed Source code dir's name

Related