"expo start --web" suddenly failing with "Body must be a string. Received: undefined" - react-native

I have just recently started with React Native and expo.
After completing a test app in the local web/dev server, I have been able to get it to work on an Android phone over a USB connection. But now the previously working web/dev server is failing:
> expo start --web
Starting project at C:\...\testproject
Body must be a string. Received: undefined.
Error: Body must be a string. Received: undefined.
at devAssert (C:\...\testproject\node_modules\graphql\jsutils\devAssert.js:12:11)
at new Source (C:\...\testproject\node_modules\graphql\language\source.js:37:56)
at new Parser (C:\...\testproject\node_modules\graphql\language\parser.js:86:62)
at Object.parse (C:\...\testproject\node_modules\graphql\language\parser.js:30:16)
at Object.<anonymous> (C:\...\testproject\node_modules\graphql-tools\src\stitching\introspectSchema.ts:7:48)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! testproject#1.0.0 dev:web: `expo start --web`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the testproject#1.0.0 dev:web script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
The expo build:web command is still working though. It exports a fully functional web app to the web-build directory.
Dependencies:
"dependencies": {
"expo": "^45.0.6",
"expo-gl": "^11.3.0",
"expo-keep-awake": "^10.1.1",
"expo-navigation-bar": "^1.2.0",
"expo-splash-screen": "~0.15.1",
"expo-status-bar": "^1.3.0",
"expo-three": "^6.1.0",
"expo-web-browser": "~10.2.1",
"react": "17.0.2",
"react-dom": "^18.2.0",
"react-native": "0.68.2",
"react-native-safe-area-context": "^4.3.1",
"react-native-screens": "^3.13.1",
"react-native-web": "^0.18.1",
"three": "^0.141.0"
},
"devDependencies": {
"#babel/core": "^7.18.5",
"#expo/webpack-config": "^0.16.24",
"#types/babel__core": "^7.1.19",
"#types/babel__template": "^7.4.1",
"#types/react": "~18.0.14",
"#types/react-native": "^0.69.0",
"#types/three": "^0.141.0",
"#typescript-eslint/eslint-plugin": "^5.29.0",
"#typescript-eslint/parser": "^5.29.0",
"eas-cli": "^0.54.1",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"expo-cli": "^5.4.11",
"expo-dev-client": "^1.0.0",
"husky": "^8.0.0",
"prettier": "^2.7.1",
"typescript": "~4.7.4"
}

Problem solved.
expo start -c -w (with -c to clear the cache) revealed the problem.
Apparently a dependency update had gone wrong; React is at 17, and React-DOM and the types are at 18. Upgrading all to 18 resulted in new/different errors, so I have now downgraded all to 17 and the dev server is working again.

for me, I had expo-cli as a dependency, as soon as I removed this, the message went away

I had expo-cli(v5.4.7) as a dev dependency. Upgrading to v6.0.6 made it work for me

Related

pod install error on react native project

When I cd ios && pod install, I keep getting this error.
I tried several things like
delete node_modules and yarn install again, yarn cache clean, pod deintegrate, etc., but no luck.
❯ pod install
error Failed to load configuration of your project.
[!] Invalid `Podfile` file: 859: unexpected token at 'Error: ENOENT: no such file or directory, lstat '/Users/user/dev/fondee-rn-webview/ios/node_modules/#bam.tech/react-native-make'
at Object.lstatSync (node:fs:1514:3)
at /Users/user/dev/fondee-rn-webview/node_modules/graceful-fs/polyfills.js:319:16
at Object.<anonymous> (/Users/user/dev/fondee-rn-webview/node_modules/#bam.tech/react-native-make/react-native.config.js:9:13)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at module.exports (/Users/user/dev/fondee-rn-webview/node_modules/cosmiconfig/node_modules/import-fresh/index.js:28:9)
info Run CLI with --verbose flag for more details.
'.
# from /Users/user/dev/fondee-rn-webview/ios/Podfile:24
# -------------------------------------------
# target 'fondee' do
> config = use_native_modules!
#
# -------------------------------------------
How can I successfully install pod?
I did update all the packages (yarn upgrade --latest).
Here is my package.json:
"dependencies": {
"#notifee/react-native": "7.2.0",
"#react-native-async-storage/async-storage": "^1.17.10",
"#react-native-clipboard/clipboard": "^1.8.5",
"#react-native-firebase/app": "^16.4.6",
"#react-native-firebase/messaging": "^16.4.6",
"#types/react": "^18.0.26",
"react": "18.2.0",
"react-native": "0.70.6",
"react-native-device-info": "^10.3.0",
"react-native-permissions": "^3.6.1",
"react-native-progress": "^5.0.0",
"react-native-send-intent": "^1.3.0",
"react-native-splash-screen": "^3.3.0",
"react-native-webview": "^11.15.0"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"#babel/runtime": "^7.12.5",
"#bam.tech/react-native-make": "^3.0.3",
"#react-native-community/eslint-config": "^3.2.0",
"#types/jest": "^29.2.4",
"#types/react-native": "^0.70.7",
"#types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.3.1",
"eslint": "^8.29.0",
"jest": "^29.3.1",
"metro-react-native-babel-preset": "^0.73.4",
"react-test-renderer": "18.2.0",
"typescript": "^4.4.4"
},
"resolutions": {
"#types/react": "^18.0.26"
},
The error is occurring because #bam.tech/react-native-make does not have pod file. Why are you using this package? The package is old and has only 20 weekly downloads.
You can follow this blog to create splash screens.

Error while upgrading EXPO version from SDK 42 to 44

I just tried to upgrade my expo app from SDK version 42 to version 44. I did the following commands:
npm i -g expo-cli
expo upgrade
When I try to run npm install i get this:
The expo package was found in your package.json but we couldn't resolve the Expo SDK version. Run npm install and then try this command again.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: expo-standard-web-crypto#1.2.0
npm ERR! Found: expo-random#12.1.2
npm ERR! node_modules/expo-random
npm ERR! expo-random#"~12.1.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional expo-random#"12.1.0" from expo-standard-web-crypto#1.2.0
npm ERR! node_modules/expo-standard-web-crypto
npm ERR! expo-standard-web-crypto#"^1.1.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: expo-random#12.1.0
npm ERR! node_modules/expo-random
npm ERR! peerOptional expo-random#"12.1.0" from expo-standard-web-crypto#1.2.0
npm ERR! node_modules/expo-standard-web-crypto
npm ERR! expo-standard-web-crypto#"^1.1.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/michaelschmitz/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/michaelschmitz/.npm/_logs/2022-02-21T19_18_50_348Z-debug.log
I've never updated expo before and am unfamiliar with working with dependencies and package.jsons
here is my package.json as well:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"update-deps": "npm install -g npm && npm install -g expo-cli && npm install",
"build-ios": "expo bi --release-channel beta -t archive",
"build-android": "expo ba --release-channel beta -t app-bundle"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"#expo/vector-icons": "^12.0.0",
"#react-native-community/slider": "4.1.12",
"#react-native-community/viewpager": "5.0.11",
"#react-native-masked-view/masked-view": "0.2.6",
"#react-navigation/drawer": "^5.12.9",
"#react-navigation/native": "^5.9.8",
"#react-navigation/stack": "^5.14.9",
"base-64": "^1.0.0",
"create-react-class": "^15.7.0",
"expo": "^44.0.0",
"expo-asset": "~8.4.6",
"expo-constants": "~13.0.1",
"expo-file-system": "~13.1.4",
"expo-font": "~10.0.4",
"expo-linking": "~3.0.0",
"expo-mail-composer": "~11.1.0",
"expo-notifications": "~0.14.0",
"expo-print": "~11.1.0",
"expo-sharing": "~10.1.0",
"expo-splash-screen": "~0.14.1",
"expo-sqlite": "~10.1.0",
"expo-standard-web-crypto": "^1.1.0",
"expo-status-bar": "~1.2.0",
"expo-web-browser": "~10.1.0",
"moment": "^2.29.1",
"native-base": "^2.13.15",
"pdf-lib": "^1.16.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-actionsheet": "^2.4.2",
"react-native-chart-kit": "^5.6.1",
"react-native-datepicker": "^1.7.2",
"react-native-elements": "^2.3.2",
"react-native-gesture-handler": "~2.1.0",
"react-native-modal": "^11.10.0",
"react-native-modal-picker": "^0.0.16",
"react-native-paper": "^4.9.2",
"react-native-reanimated": "~2.3.1",
"react-native-safe-area-context": "3.3.2",
"react-native-screens": "~3.10.1",
"react-native-simple-time-picker": "^0.2.0",
"react-native-svg": "12.1.1",
"react-native-web": "0.17.1",
"utf8": "^3.0.0",
"uuid": "^8.3.2",
"expo-random": "~12.1.1",
"expo-updates": "~0.11.6"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"#types/react": "~17.0.21",
"#types/react-dom": "~17.0.9",
"#types/react-native": "~0.64.12",
"#types/uuid": "^8.3.1",
"#typescript-eslint/eslint-plugin": "^4.29.3",
"#typescript-eslint/parser": "^4.29.3",
"eslint": "^7.32.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-react-native": "^3.11.0",
"jest-expo": "^44.0.0",
"typescript": "~4.3.5"
},
"private": true
}
This is in a react-native app and I was previously using version 42.
From your error you should revert back to your last working Expo 42 commit. Then do the following
npm uninstall expo-random
expo install expo-standard-web-crypto
The first will remove any direct dependency to expo-random from your package.json.
The second will reinstall expo-standard-web-crypto to the currently supported version for Expo 42.
Do you your test and commit if it works.
Then retry the update.
General process
The general process I have when doing an upgrade is:
determine what direct dependencies are not needed by the app and uninstall them or move them to devDependencies if it should've been a dev dependency like jest, #types etc.
test to make sure app still works
attempt upgrade
note the errors and deal with the problematic dependencies
dealing with the problematic dependency may simply be updating the version of the dep, or
revendor the improper dependencies yourself since it may take months for any fix to go through upstream,
change your code so you don't use it because the upstream may no longer be maintained except by renovate bots

react native upgrade library conflict

I am working with a react native project where the existing libraries is compiled to support Android level 29 but now it is mandatory to upgrade to level 30, so I am trying to upgrade the library by running npx react-native upgrade
info No version passed. Fetching latest...
(node:38396) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
info Fetching diff between v0.61.5 and v0.65.1...
info Applying diff...
warn Excluding files that exist in the template, but not in your project:
error Automatically applying diff failed. We did our best to automatically upgrade as many files as possible
warn Continuing after failure. Some of the files are upgraded but you will need to deal with conflicts manually
info Installing "react-native#0.65.1" and its peer dependencies...
error Command failed: npm install --save --save-exact react-native#0.65.1 react#17.0.2
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: #react-native-community/async-storage#1.11.0
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"17.0.2" from the root project
npm ERR! peer react#"*" from #react-native-community/checkbox#0.4.2
npm ERR! node_modules/#react-native-community/checkbox
npm ERR! #react-native-community/checkbox#"^0.4.2" from the root project
npm ERR! 16 more (#react-native-community/datetimepicker, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^16.8" from #react-native-community/async-storage#1.11.0
npm ERR! node_modules/#react-native-community/async-storage
npm ERR! #react-native-community/async-storage#"^1.8.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react#16.14.0
npm ERR! node_modules/react
npm ERR! peer react#"^16.8" from #react-native-community/async-storage#1.11.0
npm ERR! node_modules/#react-native-community/async-storage
npm ERR! #react-native-community/async-storage#"^1.8.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
I see ex. async-storage is causing the trouble here. I attach my package.json here, please guide me through the upgrade process?
"dependencies": {
"#react-native-community/async-storage": "^1.8.1",
"#react-native-community/checkbox": "^0.4.2",
"#react-native-community/datetimepicker": "^2.4.3",
"#react-native-community/masked-view": "^0.1.7",
"#react-native-firebase/app": "^8.1.0",
"#react-native-firebase/messaging": "^7.4.1",
"#react-navigation/bottom-tabs": "^5.2.4",
"#react-navigation/native": "^5.1.0",
"#react-navigation/stack": "^5.2.1",
"base-64": "^0.1.0",
"es6-shim": "^0.35.5",
"events": "^3.2.0",
"i18n-js": "^3.5.1",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-24h-timepicker": "^1.1.0",
"react-native-common-date-picker": "^2.3.1",
"react-native-date-picker": "^3.2.5",
"react-native-document-picker": "^4.0.0",
"react-native-elements": "^1.2.7",
"react-native-file-type": "0.0.8",
"react-native-fs": "^2.16.6",
"react-native-gesture-handler": "^1.6.0",
"react-native-linear-gradient": "^2.5.6",
"react-native-localize": "^1.3.4",
"react-native-popup-menu": "^0.15.7",
"react-native-push-notification": "^4.0.0",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.3.0",
"react-native-snap-carousel": "^3.8.4",
"react-native-svg": "^12.0.3",
"react-native-svg-charts": "^5.3.0",
"react-native-swipe-list-view": "^3.1.0",
"react-native-vector-icons": "^6.6.0",
"react-native-view-overflow": "0.0.5",
"react-relay": "^9.1.0",
"relay-runtime": "^9.1.0",
"rn-apple-healthkit": "^0.8.0",
"rn-fetch-blob": "^0.12.0",
"styled-components": "^5.1.1",
"twilio": "^3.48.1",
"twilio-chat": "^4.0.0"
},
my target lib for react native is the latest, but of course any lower version that make android level 30 will work
"dependencies": {
"react": "17.0.2",
"react-native": "0.65.1"
},

Laravel and Vue3 upgrade issues with the vue-template-compiler

I am trying to upgrade from Vue2 to Vue3 but getting errors.
I have installed vue3 latest version, installed #vue/compiler-sfc and tried to remove vue-template-compiler but when I do npm run dev keeps getting below error, I have gone through lots of SO posts but still getting this error.
Vue3 doesn't need vue-template-compiler but why I am still getting below error. Could anyone help please? Thanks!
Module Error (from ./node_modules/vue-loader/lib/index.js):
[vue-loader] vue-template-compiler must be installed as a peer dependency, or a compatible compiler implementation must be passed via options.
Module build failed (from ./node_modules/vue-loader/lib/index.js):
TypeError: Cannot read property 'parseComponent' of undefined
at parse(...\node_modules\#vue\component-compiler-utils\dist\parse.js:15:23)
at Object.module.exports(...\node_modules\vue-loader\lib\index.js:67:22)
My package.json file looks like this:
"devDependencies": {
"#types/jquery": "^3.5.5",
"#vue/compiler-sfc": "^3.1.2",
"axios": "^0.21.1",
"bootstrap": "^4.6.0",
"cross-env": "^7.0.3",
"jquery": "^3.6",
"laravel-mix": "^6.0.19",
"lodash": "^4.17.21",
"popper.js": "^1.16.1",
"postcss": "^8.3.0",
"resolve-url-loader": "^3.1.2",
"sass": "^1.32.13",
"sass-loader": "^7.1.0",
"ts-loader": "^9.2.2",
"typescript": "^4.3.2",
"vue": "^3.1.2",
"vue-loader": "^15.9.7",
"webpack": "^5.39.1"
},
"dependencies": {
"#babel/core": "^7.14.6",
"#babel/preset-env": "^7.14.7",
"#fortawesome/fontawesome-free": "5.*",
"#popperjs/core": "^2.9.2",
"vue-router": "^4.0.10"
}
packages.json doesn't have vue-template-compiler. I have tried removing while node_modules folder and did npm install and npm run dev but these errors are still appearing.
Thanks
If anyone else facing this issue, I did below steps to solve this issue:
Upgraded vue-loader to version v16.1.2
Removed node_modules folder from the root directory
Removed package-lock.json from the root directory
Run npm install
npm run dev
Now files compiled successfully.
Hope its helpful.

webpack- peer dependency versioning mismatch issue?

While installing npm packages I am getting peer dependencies versioning mismatch issue.
Error -
npm ERR! peerinvalid The package webpack#2.1.0-beta.12 does not
satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer babel-loader#6.2.4 wants webpack#1 || ^2.1.0-beta
npm ERR! peerinvalid Peer karma-webpack#1.7.0 wants webpack#^1.4.0
npm ERR! peerinvalid Peer webpack-dev-server#2.0.0-beta wants webpack#>=2.0.3-beta <3
Has any one faced something like this?
package.json file
{
"private": true,
"dependencies": {
"todomvc-app-css": "2.0.4",
"todomvc-common": "1.0.2"
},
"devDependencies": {
"babel": "6.5.2",
"babel-core": "6.8.0",
"babel-eslint": "6.0.4",
"babel-loader": "6.2.4",
"babel-plugin-__coverage__": "1.11.111",
"babel-preset-es2015-webpack": "6.4.1",
"babel-preset-stage-2": "6.5.0",
"chai": "3.5.0",
"cpy-cli": "1.0.0",
"css-loader": "0.23.1",
"eslint": "2.9.0",
"eslint-config-kentcdodds": "6.2.1",
"eslint-loader": "1.3.0",
"ghooks": "1.2.1",
"istanbul": "0.4.3",
"karma": "0.13.22",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "1.0.1",
"karma-coverage": "1.0.0",
"karma-mocha": "1.0.1",
"karma-webpack": "1.7.0",
"mocha": "2.5.3",
"npm-run-all": "1.8.0",
"opt-cli": "1.4.2",
"rimraf": "2.5.2",
"style-loader": "0.13.1",
"webpack": "^2.0.0-beta",
"webpack-dev-server": "2.0.0-beta",
"webpack-validator": "2.1.2"
}
Please suggest what exactly, I am doing wrong?
Your error message explain everything:
You use webpack 2 but karma-webpack wants to webpack 1. You can:
downgrade webpack 2 to version 1 and downgrade webpack-dev-server to version 1.
or
remove karma-webpack