yup-phone icon indicating copy to clipboard operation
yup-phone copied to clipboard

TypeError: (0 , _yup.string)(...).phone is not a function

Open leonel-os opened this issue 3 years ago • 10 comments

Hi,

Today I updated yup-phone to last version. Then one of my validators stops working and I got the following error:

C:\Users\User\Documents\Momento\development\Wallet\apis\transactions\src\validators\createUserValidators.js:42
const phoneSchema = (0, _yup.string)().phone('US', true).required();
                                       ^

TypeError: (0 , _yup.string)(...).phone is not a function
    at Object.<anonymous> (C:\Users\User\Documents\Momento\development\Wallet\apis\transactions\src\validators\/createUserValidators.js:37:37)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Module._compile (C:\Users\User\Documents\Momento\development\Wallet\apis\transactions\node_modules\pirates\lib\index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Object.newLoader [as .js] (C:\Users\User\Documents\Momento\development\Wallet\apis\transactions\node_modules\pirates\lib\index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\User\Documents\Momento\development\Wallet\apis\transactions\src\resolvers\users\/CreateUser.js:6:1)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Module._compile (C:\Users\User\Documents\Momento\development\Wallet\apis\transactions\node_modules\pirates\lib\index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Object.newLoader [as .js] (C:\Users\User\Documents\Momento\development\Wallet\apis\transactions\node_modules\pirates\lib\index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
[nodemon] app crashed - waiting for file changes before starting...

I went back to version 1.2.12 and the issue went away.

Hope you can help me. Regards!

Leonel

leonel-os avatar Nov 23 '20 14:11 leonel-os

I'm having the same issue.

nourmalaeb avatar Nov 24 '20 14:11 nourmalaeb

I was also running into this problem. Downgrading to yup-phone 1.2.12 (or even 1.2.8) didn't solve my issue. I believe the root cause here is the way npm handles caret version rules for pre-1.x packages. My project's package.json specified yup ^0.31.0 (the latest as of this writing), but yup-phone specifies ^0.30.0, so a compatible version couldn't be found. I resolved this by switching my package.json to yup ^0.30.0.

paulstraw avatar Nov 25 '20 01:11 paulstraw

Same error here, tried moving it back to 1.2.12 and yup back to ^0.27.0 but didn't work

diego06884 avatar Dec 04 '20 17:12 diego06884

@diego06884 as noted in my previous comment, you need to use the same yup minor version as the minor version specified in yup-phone. In your example of yup-phone 1.2.12, that would mean yup 0.29.1

paulstraw avatar Dec 04 '20 17:12 paulstraw

We were able to resolve this by uninstalling yup and yup-phone.

then installing [email protected] first

npm remove yup
npm remove yup-phone
npm install [email protected]

trilibi avatar Dec 18 '20 23:12 trilibi

Thanks for reporting.

Can any one file a PR for the fix? Thanks

abhisekp avatar Jan 03 '21 18:01 abhisekp

this repo doesnt'work

jamesjara avatar Nov 14 '21 05:11 jamesjara

@jamesjara @leonel-os I've updated the project. Kindly, check. It's working in codesandbox.

abhisekp avatar Nov 14 '21 20:11 abhisekp

I was also facing this issue, but resolved this by having the version of yup and yup-phone to be exactly the same as in the codesandbox

Rahul-sinha84 avatar Apr 18 '23 06:04 Rahul-sinha84

I was also facing this issue

VsevolodKurochka avatar Jan 20 '24 14:01 VsevolodKurochka