react-native-svg not resolved | victory-native - react-native

I am trying to work with victory-native package for graph for react-native platform. I have installed both victory-native and react-native-svg with --save command. And then I also linked them with
react-native link but now when I do react-native start it throws the following error:
error: bundling failed: Error: While trying to resolve module `react-native-
svg` from file `/Users/keshav/projects/PropertyFinder/node_modules/victory-
native/lib/components/victory-primitives/line.js`, the package
`/Users/keshav/projects/PropertyFinder/node_modules/react-native-svg/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved
(`/Users/keshav/projects/PropertyFinder/node_modules/react-native-svg/index.js`. Indeed, none of these files exist:
* `/Users/keshav/projects/PropertyFinder/node_modules/react-native-svg/index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
* `/Users/keshav/projects/PropertyFinder/node_modules/react-native-svg/index.js/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
at ResolutionRequest.resolveDependency
(/Users/keshav/projects/PropertyFinder/node_modules/metro/src/node-
haste/DependencyGraph/ResolutionRequest.js:104:15)
```
My package.json:
"react": "16.3.0-alpha.2",
"react-native": "0.54.2",
"react-native-svg": "^6.3.0",
"react-navigation": "^1.5.7",
"simple-swizzle": "^0.2.2",
"superagent": "^3.8.2",
"victory-native": "^0.17.2"
What is wrong here?

I met the same problem.But the different is i used the 'react-native-tab-navigator'.I've tried many times with different ways until i restarted Xcode and rebuilt the project.I hope this can help you.

Late to the party, but I had to modify my metro.config.js file as follows:
module.exports = {
...
resolver: {
sourceExts: ['js', 'jsx', 'ts', 'tsx']
}
}
I think this is to help metro resolve paths beyond js, jsx, etc.

Related

Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'

Since the ViewPropTypes has been removed from 'react-native' and the packages using it didn't update. this error appears after building the app
ERROR Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'.
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
packages I'm using:
"#react-native-clipboard/clipboard": "^1.10.0",
"#react-native-community/checkbox": "^0.5.12",
"#react-native-firebase/app": "^14.11.0",
"#react-native-firebase/auth": "^14.9.4",
"#react-native-firebase/database": "^14.11.0",
"#react-native-firebase/firestore": "^14.11.0",
"#react-native-google-signin/google-signin": "^7.2.2",
"#react-native-masked-view/masked-view": "github:react-native-masked-view/masked-view",
"#react-native-picker/picker": "^2.4.1",
"#react-navigation/bottom-tabs": "^6.3.1",
"#react-navigation/native": "^6.0.10",
"#react-navigation/stack": "^6.2.1",
"axios": "^0.27.2",
"base-64": "^1.0.0",
"num-words": "^1.2.2",
"numeral": "^2.0.6",
"pdf-lib": "^1.17.1",
"react": "17.0.2",
"react-native": "^0.69.0",
"react-native-blob-util": "^0.16.1",
"react-native-country-picker-modal": "^2.0.0",
"react-native-date-picker": "^4.2.2",
"react-native-fbsdk-next": "^8.0.5",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^2.5.0",
"react-native-html-to-pdf": "^0.12.0",
"react-native-pdf": "^6.5.0",
"react-native-picker-select": "^8.0.4",
"react-native-progress": "^5.0.0",
"react-native-radio-input": "^0.9.4",
"react-native-ratings": "^8.1.0",
"react-native-safe-area-context": "^4.2.5",
"react-native-screens": "^3.13.1",
"react-native-share": "^7.5.0",
"react-native-signature-canvas": "^4.3.1",
"react-native-vector-icons": "^9.1.0",
"react-native-webview": "^11.21.2",
"react-scripts": "^5.0.1"
Any solution?
I can recommend doing the steps outlined in this github discussion.
Steps
Install patch-package, this will later be used to make the changes more persistent.
Install deprecated-react-native-prop-types by running npm install deprecated-react-native-prop-types or yarn add deprecated-react-native-prop-types
Now you have to hack the node_modules. Go to node_modules/react-native/index.js starting around line 436 and change this:
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
invariant(
false,
"ColorPropType has been removed from React Native. Migrate to " +
"ColorPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get EdgeInsetsPropType(): $FlowFixMe {
invariant(
false,
"EdgeInsetsPropType has been removed from React Native. Migrate to " +
"EdgeInsetsPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get PointPropType(): $FlowFixMe {
invariant(
false,
"PointPropType has been removed from React Native. Migrate to " +
"PointPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get ViewPropTypes(): $FlowFixMe {
invariant(
false,
"ViewPropTypes has been removed from React Native. Migrate to " +
"ViewPropTypes exported from 'deprecated-react-native-prop-types'.",
);
},
to this:
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").ColorPropType
},
get EdgeInsetsPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").EdgeInsetsPropType
},
get PointPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").PointPropType
},
get ViewPropTypes(): $FlowFixMe {
return require("deprecated-react-native-prop-types").ViewPropTypes
},
Run npx patch-package react-native to save the patch.
Rebuild the app.
Only thing to keep in mind is that this patch will need to be reapplied with every upgrade to react-native, or until the libraries in question are updated to import from deprecated-react-native-prop-types instead.
Props to goguda for providing this answer.
I had the same error I followed the following steps and I resolved it. It arises because react-native has removed the view prop types from the library but still some external modules require the use of it.
Run the command in the terminal
npm i deprecated-react-native-prop-types#2.2.0
Go to the node modules and find the module that you are using in my case it was "react-native-camera"
Navigate into the src folder of the module file (in my case it was in RNCamera.js) and look for
import {
findNodeHandle,
Platform,
NativeModules,
ViewPropTypes,
requireNativeComponent,
View,
ActivityIndicator,
Text,
StyleSheet,
PermissionsAndroid,
} from 'react-native';
In the following code remove the ViewPropTypes and paste the following command below this
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
save the file and run it again, Hope it helps <3
I had the same error using react-native-camera. I fix it by installing npm i deprecated-react-native-prop-types#2.2.0 and replacing in node_modules/react-native-camera
all imports in files.
import { ViewPropTypes } from 'react-native';
for
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
In case anyone is getting the error with react-native-snap-carousel this is another way to fix it:
npm i --save react-native-snap-carousel#4.0.0-beta.6
github issue
I had the same error using react-native-snap-carousel. I fix it by replacing in node_modules/react-native-snap-carousel
Check All files and change this import
import { ViewPropTypes } from 'react-native';
with this and this error gone
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
I was facing this problem (Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable.) when I used drawer navigation
so I follow this step
I hope this will help someone
EDIT -
For me.. This error represented a mismatch violation with an older version of Expo Go in the simulator and the version of Expo Cli I was running. It was important that I upgraded each version of Expo one version at a time. It had nothing to do with my React or React Native code. As of Expo 46, expo upgraded the ios simulator with a prompt so the fix below i only relevant below version 46.
In my case, I am using Expo managed Workflow and this error popped up after I upgraded Expo Go on the ios simulator, which prompted me to have to upgrade Expo because the simulator wouldn't allow the version of Expo I was using (43) . After upgrading Expo, and running the simulator, I was greeted with this error, which sent me down a rabbit hole, (where this question is one of the only relevant search results) of trying to upgrade react native to be compatible with the new Expo version and so on. However, this error persisted no matter what version of react native I was using. So finally I tested a different project on the same simulator and found that the actual simulator was throwing the same error on a new project with all the latest versions.
My solution was too simple.
Install a new Simulator with the version of Expo the project is running on. While in the root of the Expo project, in the terminal, I ran
expo client:install:ios
After that, for this project these exact errors completely went away and the Simulator ran fine. I know that this is probably not a long-term fix for the actual error and that upgrading Expo and React Native is going to be necessary and this may not be the issue for many people, but in order to keep working on the project, this allowed me to move forward.
This works for me, just installed these packages. Try it, it might help you as well.
expo install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context #react-native-community/masked-view
I had the same issue after upgrading to the new RN v0.69. Changing node_modules/react-native-camera would solve the problem locally. However, we know that when the node dependencies need to be installed from scratch - in a CI/CD process for example - the changes at 3rd party library need to be done over again. So, a better solution I suggest is to intercept the react-native-camera component at build runtime level using the babel-plugin-module-resolver as suggested here https://github.com/psycheangel/deprecated-with-module-resolver. I did another way because this solution did not work for me since it's more generic and got conflict with other stuffs I have on my project. Still using the same babel resolver plugin but to address the specific problem with react-native-camera component, this is the way I did based on the above solution by psycheangel:
Step 1
Install the babel resolver plugin and the turn around dependency:
npm install --save-dev babel-plugin-module-resolver deprecated-react-native-prop-types
or
yarn add --dev babel-plugin-module-resolver deprecated-react-native-prop-types
Step 2
create resolver/react-native/index.js with this code:
import * as ReactNative from 'react-native'
import * as DeprecatedPropTypes from 'deprecated-react-native-prop-types'
delete ReactNative['ColorPropType']
delete ReactNative['EdgeInsetsPropType']
delete ReactNative['ImagePropTypes']
delete ReactNative['PointPropType']
delete ReactNative['TextInputPropTypes']
delete ReactNative['TextPropTypes']
delete ReactNative['ViewPropTypes']
module.exports = {
...ReactNative,
...DeprecatedPropTypes,
}
Step 3
add module resolver plugin config to babel.config.js:
const path = require('path')
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'module-resolver',
{
root: ['.'],
resolvePath(sourcePath, currentFile) {
if (
sourcePath === 'react-native' &&
currentFile.includes('react-native-camera/src/RNCamera.js')
) {
console.log('resolver', sourcePath, currentFile)
return path.resolve(__dirname, 'resolver/react-native')
}
},
},
],
],
}

how to resolve this firebase module versioning error?

Here's a list of my firebase dependencies in package.json:
"#react-native-firebase/admob": "^6.2.0",
"#react-native-firebase/app": "^6.2.0",
"#react-native-firebase/auth": "^6.2.0",
"#react-native-firebase/crashlytics": "^6.2.0",
"#react-native-firebase/messaging": "^6.2.0",
I just added the last "messaging" dependency in that list and then ran npm install. I included the following import for a component:
import messaging from '#react-native-firebase/messaging';
Then I included the following line of code in one of the component functions:
const enabled = await firebase.messaging().hasPermission();
My app is currently returning the following error:
Error: Requiring module "node_modules\#react-native-firebase\messaging\lib\index.js", which threw an exception: Error: You've attempted to require '#react-native-firebase\messaging' version '6.3.4', however, the '#react-native-firebase\app' module is of a different version (6.2.0). All React Native Firebase modules must be of the same version. Please ensure they match up in your package.json file and re-run yarn/npm install
I inspected my project's node_modules\#react-native-firebase\messaging\package.json. Here's a subset of some of the version refs within that file:
"_from": "#react-native-firebase/messaging#^6.2.0",
"_id": "#react-native-firebase/messaging#6.3.4",
"_requested": {
"raw": "#react-native-firebase/messaging#^6.2.0",
"rawSpec": "^6.2.0",
"fetchSpec": "^6.2.0"
},
"_resolved": "https://registry.npmjs.org/#react-native-firebase/messaging/-/messaging-6.3.4.tgz",
"_spec": "#react-native-firebase/messaging#^6.2.0",
"version": "6.3.4"
So it looks like the ^6.2.0 version spec that I configured is getting read as expected, but then some aspect of the npm install process redirects the install to version 6.3.4. Any idea why this is happening? All of the firebase modules are required to be of the same version, so if I want to use the firebase messaging module then do I need to set the version to all of the other firebase modules to "^6.3.0" in my project's package.json? Or do I have other options for a workaround?

Build error: missing babel-preset-expo in expo mobile app

I'm new to react-native and am in the early stages of creating an app with Expo. I had a working app until installing redux. Currently I am getting the following error from the XDE:
Problem checking node_modules dependencies: Unexpected end of JSON input
and the following from the ios simulator:
Building JavaScript bundle: error
TransformError: ../app/main.js: Couldn't find preset "babel-preset-expo" relative to directory "../app/"
I believe my node modules contain valid JSON. It should be noted that I'm using a more current version of react-native than expo.
I experienced this issue when I tried moving to expo version 21.0.0.
You should try to delete your node modules and use yarn to install.
package.json
dependencies:{
"babel-preset-expo" : "^4.0.0",
"expo": "^21.0.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-21-0.2.tar.gz"
}
my .babelrc
{
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
}
}

SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (1:0)

I keep hitting this error. Its happened a few times recently and now I can't get rid of it. I'm using MobX in my React Native project and so I need something in my .babelrc so I have decorator support:
{
"presets": ["react-native"],
"plugins": ["transform-decorators-legacy"]
}
I've tried a few difference variations but all give me the error below. If I remove it, I get an error due to decorators not being supported.
SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (1:0)
at Parser.pp$5.raise (/path-to/node_modules/babylon/lib/index.js:4246:13)
at Parser.pp$1.parseStatement (/path-to/node_modules/babylon/lib/index.js:1749:16)
at Parser.pp$1.parseBlockBody (/path-to/node_modules/babylon/lib/index.js:2133:21)
at Parser.pp$1.parseTopLevel (/path-to/node_modules/babylon/lib/index.js:1645:8)
at Parser.parse (/path-to/node_modules/babylon/lib/index.js:1537:17)
at Object.parse$1 [as parse] (/path-to/node_modules/babylon/lib/index.js:6466:37)
at extractDependencies (/path-to/node_modules/react-native/packager/react-packager/src/JSTransformer/worker/extract-dependencies.js:29:23)
at transform (/path-to/node_modules/react-native/packager/react-packager/src/JSTransformer/worker/index.js:53:9)
at module.exports (/path-to/node_modules/react-native/packager/transformer.js:130:3)
at transformCode (/path-to/node_modules/react-native/packager/react-packager/src/JSTransformer/worker/index.js:27:3)
transformed 35/139 (25%)/path-to/node_modules/babylon/lib/index.js:4249
throw err;
I've tried removing my node_modules and reinstalling a few times. I'm using yarn. Also removed the lock file before running yarn install again.
I followed this guide to get the Babel plugins installed.
My package.json looks like:
"dependencies": {
"apsl-react-native-button": "^3.0.0",
"mobx": "^2.5.0",
"mobx-react": "^3.5.5",
"react": "15.3.2",
"react-native": "0.37.0",
"react-native-autogrow-textinput": "^2.0.3",
"react-native-awesome-button": "^1.6.0",
"react-native-couchbase-lite": "git://github.com/adamski/react-native-couchbase-lite.git#gradle-experimental",
"react-native-keep-awake": "git://github.com/adamski/react-native-keep-awake.git#experimental-gradle",
"react-native-keyboard-aware-view": "^0.0.11",
"react-native-keyboard-dodging-view": "git://github.com/adamski/react-native-keyboard-dodging-view#upper-text-inputs",
"react-native-modalbox": "^1.3.4",
"react-native-navigation": "git://github.com/adamski/react-native-navigation.git#gradle-experimental-update",
"react-native-searchbar": "^0.4.2",
"react-native-simple-store": "^1.0.1",
"react-native-swipe-list-view": "^0.3.1"
},
"devDependencies": {
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-react-native": "^1.9.1"
}
I tried updating to RN 0.38 but still get the same error.
Running ag babylon yields
yarn.lock
200: babylon "^6.11.0"
885: babylon "^6.11.0"
896: babylon "^6.11.0"
911:babylon#^6.11.0, babylon#^6.13.0, babylon#^6.13.1:
913: resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.14.1.tgz#956275fab72753ad9b3435d7afe58f8bf0a29815"
3478: babylon "^6.13.0"
3555: babylon "^6.13.1"
which suggests a conflict among different versions of babylon?
Can anyone tell me what this error message actually means? Is it something in my code, or is it a mismatch of babel versions among my modules?
I think there is a package for that, babel-preset-react-native-stage-0
and in your .babelrc add "react-native-stage-0/decorator-support" to your presets array
I had the same problem. At the end my solution was to delete the .babelrc file all together. Then, I had to install some presets and add them as dev dependencies.
Specifically:
babel-preset-es2015
babel-preset-react
babel-preset-react-native
And everything started working again.

Integrating Relay with React native

I want to integrate relay with react native.
I am getting following error:
getBabelRelayPlugin is not defined while processing preset
I used following steps to integrate react native with relay
1.Back up your project.
2. Make sure you have your GraphQL server ready and your schema.json at hand too. For more details about the latter two visit the React-Relay project page.
Ensure that you’re using npm version 3 or greater.
3.If React Native's packager (react-native start) is running somewhere in the background, you should stop it now.
4.Run: watchman watch-del-all
5.Delete the ./node_modules directory from your project.
6.Edit your package.json file, make sure it has the following:
"dependencies": {
"react": "^0.14.7",
"react-native": "facebook/react-native",
"react-relay": "^0.7.3"
},
"devDependencies": {
"babel-core": "^6.6.4",
"babel-preset-react-native": "^1.4.0",
"babel-relay-plugin": "^0.7.3"
}
Babel version is especially important. Make sure that your project uses babel 6.5 or later, we need it for the passPerPreset feature in .babelrc file.
7.Create a new file .babelrc and place it in your project's directory:
{
"presets": [
"./scripts/babelRelayPlugin",
"react-native"
],
"passPerPreset": true
}
8.Create a new file in your project's directory called babelRelayPlugin.js with the following content:
const getBabelRelayPlugin = require('babel-relay-plugin');
const schema = require('./schema.json');
module.exports = { plugins: [getBabelRelayPlugin(schema.data)] };
9Copy your schema.json file to the project's directory too.
10.Run: npm install