Home > Net >  getting error for module that doesn't exist in Package.json in react native?
getting error for module that doesn't exist in Package.json in react native?

Time:01-19

enter image description here

I am getting error for module that doesn't even exist in Package.json file. what is that and how to resolve this problem

usually i try deleting node modules and then npm install but this time i did it and got this error again

CodePudding user response:

If you want to use this library then you have to install it using

npm i @twotalltotems/react-native-otp-input

Now as u said : " module that doesn't even exist in Package.json file" and you are still importing the library e.g

"import OTPInputView from '@twotalltotems/react-native-otp-input'"

thats why it's giving the error.

just remove this line "import OTPInputView from '@twotalltotems/react-native-otp-input'"

Secondly You don't need to delete node modules every time. It should be done only in swear cases.

you can simple try npm start --Reset-cache

if you have any other confusion ,feel free to ask

CodePudding user response:

"npm install" only installs packages mentioned under package.json file.

As you are getting an error for the module which is not present under package.json, you are supposed to add that module name in package.json file as other modules are mentioned under "dependencies" object. And after adding the module name you can try "npm install".

Or

You can simply try npm install for that respective package separately, it'll automatically add that module name in package.json and will install the same for you.

for example: let's suppose you are getting an error for a package called as 'example'

npm install example

  • Related