简体   繁体   中英

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

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

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 eg

"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

"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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM