shoutem/ui

Error: Unable to resolve module `react-native/Libraries/Components/View/ViewStylePropTypes

avinashvalluru opened this issue ยท 27 comments

Error: Unable to resolve module react-native/Libraries/Components/View/ViewStylePropTypes from /home/avinash/Kinre/kinreAdmin/node_modules/react-native-render-html/src/HTMLUtils.js: Module react-native/Libraries/Components/View/ViewStylePropTypes does not exist in the Haste module map

mxvsh commented

Have you got any solution? i am also facing same issue

I am facing the same issue after update npm.

same here at

"react": "16.5.0",
"react-native": "^0.58.5",

hi, i presume you guys are using expo, try matching the RN version

https://docs.expo.io/versions/latest/sdk/

hope it helps

hlmnd commented

the same problem, try with the versions of the example of Restaurant and it worked for me:
https://github.com/shoutem/ui/blob/develop/examples/RestaurantsApp/package.json
"@shoutem/ui": "~0.23.0",
"react": "16.0.0",
"react-native": "~0.51.0",

I have a similar problem with a freshly generated app with react-native-cli
"react": "16.6.3",
"react-native": "0.58.6"

Unable to resolve module react-native/Libraries/StyleSheet/ColorPropType.js from [path of my project]/node_modules/react-native-linear-gradient/index.ios.js: Module react-native/Libraries/StyleSheet/ColorPropType.js does not exist in the Haste module map

Is there any solution or prediction for this fix? I would really like to use Shoutem, but I'm not willing to downgrade versions to do it...

hlmnd commented

Some things broke with versions >= 0.58.x.
The most recent version with which I worked is:
"react-native": " 0.57.8"

It is problem with react-native-linear-gradient.

But shoutem must update react-native-render-html too for "^4.1.1" ver., now there "3.10.0" and there is the same problem with proptypes as react-native-linear-gradient.

Solution for me - using react-native <0.58

Im using this script unless guys fix it

fix.sh file

cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js ./node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js ./node_modules/react-native/Libraries/StyleSheet/ColorPropType.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js ./node_modules/react-native/Libraries/Image/ImageStylePropTypes.js

and in package.json

{
  "scripts": {
    "postinstall": "sh ./fix.sh"
  },
  "dependencies": {
    "@shoutem/ui": "^0.23.12",
    "react": "16.6.3",
    "react-native": "0.58.5"
  }
}

Im using this script unless guys fix it

fix.sh file

cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js ./node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js ./node_modules/react-native/Libraries/StyleSheet/ColorPropType.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js ./node_modules/react-native/Libraries/Image/ImageStylePropTypes.js

and in package.json

{
  "scripts": {
    "postinstall": "sh ./fix.sh"
  },
  "dependencies": {
    "@shoutem/ui": "^0.23.12",
    "react": "16.6.3",
    "react-native": "0.58.5"
  }
}

Thanks! Works perfectly with

"@shoutem/ui": "^0.23.16",
"react": "16.6.3",
"react-native": "0.58.6"

Facing same issue still after adding
dependecies:
"@shoutem/ui": "^0.23.16",
"react": "16.6.3",
"react-native": "0.58.6"

I solved this issue by manually copy and pasting missing files to the respective folders. Same solution as @vko-online except I did it manually.

copied ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js
and pasted it in ./node_modules/react-native/Libraries/Components/View/. Changed the name of the file to ViewStylePropTypes.js

copied ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js
to ./node_modules/react-native/Libraries/StyleSheet/. File name changed to ColorPropType.js

copied ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js to ./node_modules/react-native/Libraries/Image/. File name changed to ImageStylePropTypes.js

Using the fix mentioned by @Auggysg and @vko-online worked for me.

"@shoutem/ui": "^0.23.20",
"react": "16.8.3",
"react-native": "0.59.3",

In case you want to see what works with what follow the release notes of expo i.e. sdk 32:
https://blog.expo.io/expo-sdk-v32-0-0-is-now-available-6b78f92a6c52

Im using this script unless guys fix it

fix.sh file

cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js ./node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js ./node_modules/react-native/Libraries/StyleSheet/ColorPropType.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js ./node_modules/react-native/Libraries/Image/ImageStylePropTypes.js

and in package.json

{
  "scripts": {
    "postinstall": "sh ./fix.sh"
  },
  "dependencies": {
    "@shoutem/ui": "^0.23.12",
    "react": "16.6.3",
    "react-native": "0.58.5"
  }
}

This fix doesn't work for me after RN 0.61.2 update. Has anyone this problem too?

"@shoutem/ui": "^0.23.12",
"react": "16.9.0",
"react-native": "0.61.2",

Im using this script unless guys fix it
fix.sh file

cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js ./node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js ./node_modules/react-native/Libraries/StyleSheet/ColorPropType.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js ./node_modules/react-native/Libraries/Image/ImageStylePropTypes.js

and in package.json

{
  "scripts": {
    "postinstall": "sh ./fix.sh"
  },
  "dependencies": {
    "@shoutem/ui": "^0.23.12",
    "react": "16.6.3",
    "react-native": "0.58.5"
  }
}

This fix doesn't work for me after RN 0.61.2 update. Has anyone this problem too?

"@shoutem/ui": "^0.23.12",
"react": "16.9.0",
"react-native": "0.61.2",

me too.

Im using this script unless guys fix it
fix.sh file

cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js ./node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js ./node_modules/react-native/Libraries/StyleSheet/ColorPropType.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js ./node_modules/react-native/Libraries/Image/ImageStylePropTypes.js

and in package.json

{
  "scripts": {
    "postinstall": "sh ./fix.sh"
  },
  "dependencies": {
    "@shoutem/ui": "^0.23.12",
    "react": "16.6.3",
    "react-native": "0.58.5"
  }
}

This fix doesn't work for me after RN 0.61.2 update. Has anyone this problem too?

"@shoutem/ui": "^0.23.12",
"react": "16.9.0",
"react-native": "0.61.2",

I think we should import deprecated file itself and dont use the fix.sh script anymore.
We should import like this:
import 'react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js';

Im using this script unless guys fix it
fix.sh file

cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js ./node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js ./node_modules/react-native/Libraries/StyleSheet/ColorPropType.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js ./node_modules/react-native/Libraries/Image/ImageStylePropTypes.js

and in package.json

{
  "scripts": {
    "postinstall": "sh ./fix.sh"
  },
  "dependencies": {
    "@shoutem/ui": "^0.23.12",
    "react": "16.6.3",
    "react-native": "0.58.5"
  }
}

This fix doesn't work for me after RN 0.61.2 update. Has anyone this problem too?
"@shoutem/ui": "^0.23.12",
"react": "16.9.0",
"react-native": "0.61.2",

I think we should import deprecated file itself and dont use the fix.sh script anymore like:
import 'react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js';

Do you think we should use this method?

Im using this script unless guys fix it
fix.sh file

cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js ./node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js ./node_modules/react-native/Libraries/StyleSheet/ColorPropType.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js ./node_modules/react-native/Libraries/Image/ImageStylePropTypes.js

and in package.json

{
  "scripts": {
    "postinstall": "sh ./fix.sh"
  },
  "dependencies": {
    "@shoutem/ui": "^0.23.12",
    "react": "16.6.3",
    "react-native": "0.58.5"
  }
}

This fix doesn't work for me after RN 0.61.2 update. Has anyone this problem too?
"@shoutem/ui": "^0.23.12",
"react": "16.9.0",
"react-native": "0.61.2",

I think we should import deprecated file itself and dont use the fix.sh script anymore like:
import 'react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js';

Do you think we should use this method?

Method you mentioned worked with RN < 60, after this version it seems that these files are updated and inside these files other Deprecated files are imported in another way. (for example inside DeprecatedViewStylePropTypes.js the ./DeprecatedColorPropType.js file is imported and because of that it throws error that can't find this file in that folder)

I'm adding them one by one as RN gives me the Unable to resolve module react-native/... error. I will update you with all the files in a bit. Thanks!!

Edit: It worked!

I have been having this issue since morning and I have tried every way possible and I can't get it resolved. please let me know how I can get it fixed.

/Users/flatironschool/Folder/Practice-react-native/node_modules/react-native/Libraries/StyleSheet/processColor.js
Module not found: Can't resolve '../Utilities/Platform' in '/Users/flatironschool/Folder/Practice-react-native/node_modules/react-native/Libraries/StyleSheet'

And here is my package.json

{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "^32.0.0",
"react": "16.8.3",
"react-dom": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-web": "^0.11.7"
},
"devDependencies": {
"babel-preset-expo": "^7.0.0",
"components": "^0.1.0",
"styled": "^1.0.0"
},
"private": true
}

I had more luck with this in the fix.sh file:

sed -i 's/StyleSheet\/ColorPropType.js/DeprecatedPropTypes\/DeprecatedColorPropType.js/' ./node_modules/react-native-linear-gradient/index.android.js

Any update about how to fixed it in react-native 0.60.x ?

I am using Expo SDK33 and still not works

Any update about how to fix it ? I got this issue when I'm trying to add react-native-web to existing react-native project.

Failed to compile ./node_modules/@react-native-community/art/lib/helpers.js Module not found: Can't resolve 'react-native/Libraries/StyleSheet/processColor' in '/home/anas/app/web/node_modules/@react-native-community/art/lib

When using RN > 0.60, the above scripts won't work because the react internals have explicitly changed to error on accessing the legacy PropTypes.

To fix this, you can patch react-native itself, using patch-package and post-install hooks: https://stackoverflow.com/a/73135908/4821759.

Ultimately shoutem dependencies need to be updated to versions of libraries that no longer require them, or use the correct deprecated package directly.