Unable to find module 'prompt-sync'

Shreyash Kashyap

I am trying to take under input in nodejs using prompt but it shows me the following error:

node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module 'prompt-sync'
Require stack:
- D:\Code\C++\Concepts\conditionals.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (D:\Code\C++\Concepts\conditionals.js:1:16)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'D:\\Code\\C++\\Concepts\\conditionals.js' ]
}

I have installed 'prompt-sync' using npm but the issue still persists. This is my code:

const prompt = require('prompt-sync')();
let num = prompt("Enter your age: ");
console.log(typeof num);

I have tried restarting my pc and updated nodejs to its latest version(currently 9.2.0).

Any kind of help will be appreciated.

Ralle

Clean your installed node modules like so:

npm cache verify
rm -rf node_modules
rm package-lock.json
npm i

rm works if you are under linux or gitbash on Windows. If not delete the node_modules folder and the package.lock.json. (not the package.json)

When executing the npm i, take a look if error messages comes. Not all npm packages are combatiple with all node versions.

Controll in your package.json if the prompt-sync module is in the dependency section. If not reinstall it. You need to be inside your project folder when you install a module.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Gradle sync failed: Unable to find method

Unable to find module with Gradle path. Linking to library -unspecified instead

Unable to find 'ng' in module... - broken Intellisense?

Error: Cannot find module 'browser-sync'

Gradle failed to sync with 'unable to find optional library'

Unable to find executable of python module installed by pip on Mac OSX

Unable to find font file for an imported module while using webpack

Chutzpah unable to find imported angular library module

Unable to find module qiskit_aqua.algorithms

Error: Cannot find module 'readline-sync' : Node.js

Unable to find module for event dispatcher

Unable to find Vuex module action in Nuxt

Cannot find module 'findup-sync' on running grunt

Gradle sync failed: Unable to find method after update to Gradle 4.0.0

Error: Unable to find module 'opennebula' (Meteor.JS)

unable to find spring bean xml file in another module of application

Unable to find module providers

Lua unable to find module

Unable to sync with ntp servers

ansible role unable to find module

Pyinstaller | Extrected Exe unable to find sub module

Unable to find module 'uglifyjs-webpack-plugin', even with version 1.2.7

Unable to compile TypeScript: Cannot find module 'fs'

Unable to find module 'path-to-regexp'

Jest is unable to find module from test file

Javascript unable to find module in separate directory

'can't find '__ main __' module' in command prompt

PS module ExchangeOnlineManagement unable to find type

Elixir Pheonix route unable to find appropriate module/function (module not avilable)