Expo build: TypeError: Cannot convert undefined or null to object - react-native

When I try to build .apk file via expo I get the error like:
TypeError: Cannot convert undefined or null to object
at Function.entries (<anonymous>)
at renderIntentFilterDatumEntries (/app/turtle/node_modules/#expo/xdl/build/detach/AndroidIntentFilters.js:33:17)
at /app/turtle/node_modules/#expo/xdl/build/detach/AndroidIntentFilters.js:37:70
at Array.map (<anonymous>)
at renderIntentFilterData (/app/turtle/node_modules/#expo/xdl/build/detach/AndroidIntentFilters.js:37:48)
at /app/turtle/node_modules/#expo/xdl/build/detach/AndroidIntentFilters.js:25:9
at Array.map (<anonymous>)
at renderIntentFilters (/app/turtle/node_modules/#expo/xdl/build/detach/AndroidIntentFilters.js:22:24)
at runShellAppModificationsAsync (/app/turtle/node_modules/#expo/xdl/build/detach/AndroidShellApp.js:632:115)
at async Object.createAndroidShellAppAsync (/app/turtle/node_modules/#expo/xdl/build/detach/AndroidShellApp.js:392:3)
at async runShellAppBuilder (/app/turtle/build/builders/android.js:95:9)
at async Object.buildAndroid [as android] (/app/turtle/build/builders/android.js:43:28)
at async build (/app/turtle/build/jobManager.js:181:33)
at async processJob (/app/turtle/build/jobManager.js:118:32)
at async Object.doJob (/app/turtle/build/jobManager.js:49:5)
at async main (/app/turtle/build/server.js:66:13)
In test and develop mode, everything works fine.

Check expo build does not work
Specifically check next answer:
For anyone else experiencing this issue, make sure you’re formatting your intent filter >property correctly. The proper format is shown here- https://docs.expo.io/versions/latest/config/app/#intentfilters

Related

How to resolve 'adapter_error_getUserByAccount' in NextAuth with Prisma

I'm trying to implement an auth flow in my project using Next.js + NextAuth.js + Prisma.
And I'm using GitHub Provider. It works perfectly fine on my local machine, I can sign in and redirect back to the dashboard. I thought it might be a database problem, so I've tested using my production database URL, but still works fine in the local environment. Only in the production mode error occurs.
Below is the error message I got in Vercel.
[GET] /api/auth/callback/github?code=e19191fb050f6a1708e8&state=lV7j49LEjSWE9GHMBWjQ-6WGr62yqziPqhkWURnGBWQ
15:55:11:41
2022-05-16T06:55:11.782Z 4b29fadc-0c2a-4f7a-9140-fbbb45d159f2 ERROR [next-auth][error][adapter_error_getUserByAccount]
https://next-auth.js.org/errors#adapter_error_getuserbyaccount Cannot read property 'findUnique' of undefined {
message: "Cannot read property 'findUnique' of undefined",
stack: "TypeError: Cannot read property 'findUnique' of undefined\n" +
' at getUserByAccount (/var/task/node_modules/#next-auth/prisma-adapter/dist/index.js:11:45)\n' +
' at _callee2$ (/var/task/node_modules/next-auth/core/errors.js:315:29)\n' +
' at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:63:40)\n' +
' at Generator.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:294:22)\n' +
' at Generator.next (/var/task/node_modules/regenerator-runtime/runtime.js:119:21)\n' +
' at asyncGeneratorStep (/var/task/node_modules/#babel/runtime/helpers/asyncToGenerator.js:3:24)\n' +
' at _next (/var/task/node_modules/#babel/runtime/helpers/asyncToGenerator.js:25:9)\n' +
' at /var/task/node_modules/#babel/runtime/helpers/asyncToGenerator.js:32:7\n' +
' at new Promise (<anonymous>)\n' +
' at /var/task/node_modules/#babel/runtime/helpers/asyncToGenerator.js:21:12',
name: 'TypeError'
}
2022-05-16T06:55:11.783Z 4b29fadc-0c2a-4f7a-9140-fbbb45d159f2 ERROR [next-auth][error][OAUTH_CALLBACK_HANDLER_ERROR]
https://next-auth.js.org/errors#oauth_callback_handler_error Cannot read property 'findUnique' of undefined TypeError: Cannot read property 'findUnique' of undefined
at getUserByAccount (/var/task/node_modules/#next-auth/prisma-adapter/dist/index.js:11:45)
at _callee2$ (/var/task/node_modules/next-auth/core/errors.js:315:29)
at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:294:22)
at Generator.next (/var/task/node_modules/regenerator-runtime/runtime.js:119:21)
at asyncGeneratorStep (/var/task/node_modules/#babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/var/task/node_modules/#babel/runtime/helpers/asyncToGenerator.js:25:9)
at /var/task/node_modules/#babel/runtime/helpers/asyncToGenerator.js:32:7
at new Promise (<anonymous>)
at /var/task/node_modules/#babel/runtime/helpers/asyncToGenerator.js:21:12 {
name: 'GetUserByAccountError',
code: undefined
}
I've read all related threads on GitHub issues and discussions, but still cannot find any way to resolve this problem.
You need to create a prisma file with the correct fields using "schema.prisma"
https://next-auth.js.org/adapters/prisma
then :
npx prisma db push
npx prisma generate
I have experienced a similar error which was due to improper code inside [...nextauth] file. You may double check its contents especially the prisma related portion. In my case I have included
adapter: PrismaAdapter(PrismaClient)
instead of the right format
const prisma = new PrismaClient()
export default NextAuth({
adapter: PrismaAdapter(prisma),
.........

Svelte with snowpack gives "Not Implemented: Animation" when trying to import transitions

Usually, I can import a flip or other animations in svelte like this:
import { flip } from "svelte/animate";
However, I'm unsure why I'm getting the following error in snowpack with svelte:
Build Error: #snowpack/plugin-svelte
Error: Not implemented: Animation
Source
/Users/duane/Braid/ribbon/client/src/Posts/PostsPage.svelte
Error: Not implemented: Animation
at /Users/duane/Braid/ribbon/node_modules/svelte/compiler.js:27126:28
at Array.forEach (<anonymous>)
at new InlineComponent$1 (/Users/duane/Braid/ribbon/node_modules/svelte/compiler.js:27087:26)
at /Users/duane/Braid/ribbon/node_modules/svelte/compiler.js:27358:23
at Array.map (<anonymous>)
at map_children (/Users/duane/Braid/ribbon/node_modules/svelte/compiler.js:27353:22)
at new IfBlock$1 (/Users/duane/Braid/ribbon/node_modules/svelte/compiler.js:27063:26)
at /Users/duane/Braid/ribbon/node_modules/svelte/compiler.js:27358:23
at Array.map (<anonymous>)
at map_children (/Users/duane/Braid/ribbon/node_modules/svelte/compiler.js:27353:22)
at new Fragment (/Users/duane/Braid/ribbon/node_modules/svelte/compiler.js:27410:26)
at new Component (/Users/duane/Braid/ribbon/node_modules/svelte/compiler.js:27547:26)
at Object.compile (/Users/duane/Braid/ribbon/node_modules/svelte/compiler.js:28753:24)
at Object.load (/Users/duane/Braid/ribbon/node_modules/#snowpack/plugin-svelte/plugin.js:120:31)
at async runPipelineLoadStep (/Users/duane/Braid/ribbon/node_modules/snowpack/lib/index.js:74471:28)
at async Object.buildFile (/Users/duane/Braid/ribbon/node_modules/snowpack/lib/index.js:74638:24)
Am I missing something?
It turns out this has nothing to do with snowpack.
Instead, the "Not implemented: Animation" error arises when you try to add an "animate:flip" or "transition:slide" (for example) on a component (e.g. <MySpecialButton />). The animate: and transition: attributes can only go on DOM elements like <div />, etc.

Unit Test with Jest gives TypeError: File.test.js: Cannot read property 'toString' of undefined

I have been working in React Native using Expo CLI and recently started to face issue with my Unit tests that got failed because of one common reason. Stack trace is below
Cannot read property 'toString' of undefined
at Converter.toBase64 (node_modules/convert-source-map/index.js:61:46)
at Converter.toComment (node_modules/convert-source-map/index.js:65:21)
at generateCode (node_modules/#babel/core/lib/transformation/file/generate.js:78:76)
at run (node_modules/#babel/core/lib/transformation/index.js:55:33)
at run.next (<anonymous>)
at transform (node_modules/#babel/core/lib/transform.js:27:41)
at transform.next (<anonymous>)
at evaluateSync (node_modules/gensync/index.js:244:28)
at sync (node_modules/gensync/index.js:84:14)
My node version is node:12.18.4.I wonder what caused these errors since everything was working perfectly. On my local system they are working fine, occasionally but CI process tends to fail them randomly which hinders the overall code coverage figures.
Unit test I am trying to run is very simple as written below
it('Renders Strings as expected', () => {
expect(received).toStrictEqual(expected)
})
For those of you who are still wandering around to find answer to above question.
Issue was in the library itself convert-source-map which needed to handle this exception.
I forked the actual repository and handled that exception in line 64 toBase64 method. Now the method looks like something
Converter.prototype.toBase64 = function () {
var json = this.toJSON();
return (SafeBuffer.Buffer.from(json, 'utf8') || "").toString('base64');
};
Now everything is working fine.
Original method was something like this
Converter.prototype.toBase64 = function () {
var json = this.toJSON();
return SafeBuffer.Buffer.from(json, 'utf8').toString('base64');
};

How to import images dynamically using Webpack in Electron JS (Vue JS)

I tried a lot of ways to import pngs dynamically but it keeps saying..
Uncaught (in promise) Error: Cannot find module './SGSkysTheLimit.png'
at webpackContextResolve (eval at ./src/renderer/assets/img/square sync recursive ^\.\/.*\.png$ (renderer.js:5418), <anonymous>:374:11)
at webpackContext (eval at ./src/renderer/assets/img/square sync recursive ^\.\/.*\.png$ (renderer.js:5418), <anonymous>:369:11)
at VueComponent._callee2$ (TestComponent.vue?87f2:114)
at tryCatch (runtime.js?96cf:62)
at Generator.invoke [as _invoke] (runtime.js?96cf:296)
at Generator.prototype.<computed> [as next] (runtime.js?96cf:114)
at step (asyncToGenerator.js?0f75:17)
at eval (asyncToGenerator.js?0f75:35)
at new Promise (<anonymous>)
at new F (_export.js?63b6:36)
I tried solutions like these
Example 1:
<img :src="fileName(game.key_name)">
Example 2:
<img :src="require(`../assets/img/square/${game.key_name}.png`)">
async fileName(filename) {
// Not working
const image = await require(`../assets/img/square/${filename}.png`)
return image
// Not working
return import(`../assets/img/square/${filename}.png`)
// Not working
let image = `../assets/img/square/${filename}.png`
return require(image)
// Not working
return require(`../assets/img/square/${image}`)
// Not working
var images = require.context('../assets/img/square/', false, /\.png$/)
return images('./' + filename + ".png")
// Working
return require("../assets/img/square/SGJellyfishFlow.png")
// but the problem is I need image is dynamically imported
}
App\src\renderer\assets\img\square\SGSkysTheLimit.png
I tried a lot of search on stackoverflow and github but all of them not fix my problem.

Jest unable to load module vue-cookies

console.error node_modules/vue/dist/vue.runtime.common.dev.js:621
[Vue warn]: Error in mounted hook (Promise/async): "TypeError: Cannot read property 'get' of undefined"
found in
---> <Anonymous>
<Root>
console.error node_modules/vue/dist/vue.runtime.common.dev.js:1884
TypeError: Cannot read property 'get' of undefined
at VueComponent.mounted (/home/ubuntu/vue-testing-skel/src/components/ChatApp.vue:66:1)
The line that is causing the error:
this.current_nickname = this.$cookies.get('nickname')
this.$cookies is provided by a module called vue-cookies
I have it installed and saved in my devDependencies, but it seems jest is unable to find it or load it.
I'm not sure what I have to do to make sure Jest is loading these modules properly.
Testing with Jest is meant to be self-contained. This means that global objects like this.$cookies are not available since they are interfacing with the cookies in your browser. The way to solve this is to mock the global functions. More info on how to do that here:
https://lmiller1990.github.io/vue-testing-handbook/mocking-global-objects.html#example-with-vue-i18n
To build off of #Imre_G 's answer, you need to specify a $cookies key inside your mount() or shallowMount() function, like so:
wrapper = shallowMount(ComponentName, {
localVue,
...
mocks: {
$cookies: {
get: jest.fn().mockReturnValue(null),
set: jest.fn(),
}
}
});