How to import images dynamically using Webpack in Electron JS (Vue 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.

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.

Expo build: TypeError: Cannot convert undefined or null to object

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

Javascript global variable not working as expected

I'm trying to use my "window" variable in express but i cant. Can anyone help
const { app, BrowserWindow } = require("electron")
const expapp = require("express")()
this.window
app.on("ready", () => {
this.window = new BrowserWindow({webPreferences:{ nodeIntegration: true }})
this.window.loadURL("https://www.google.com.tr")
expapp.get("/", (req,res) => {
res.render("index.ejs")
})
/* Sayfayı geri al */
expapp.get("/back", (req,res) => {
this.window.selectPreviousTab()
res.send("ok")
})
})
expapp.listen(1661, () => { console.log("1661 portu üzerinden dinleniyor") })
when i go to this route in express "/back" i get this error
TypeError: this.window.selectPreviousTab is not a function
at C:\Users\GreXLin85\Desktop\Projelerim\PC\xx\app.js:15:21
at Layer.handle [as handle_request] (C:\Users\GreXLin85\Desktop\Projelerim\PC\xx\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\GreXLin85\Desktop\Projelerim\PC\xx\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\GreXLin85\Desktop\Projelerim\PC\xx\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Users\GreXLin85\Desktop\Projelerim\PC\xx\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\GreXLin85\Desktop\Projelerim\PC\xx\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Users\GreXLin85\Desktop\Projelerim\PC\xx\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\GreXLin85\Desktop\Projelerim\PC\xx\node_modules\express\lib\router\index.js:275:10)
at expressInit (C:\Users\GreXLin85\Desktop\Projelerim\PC\xx\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request] (C:\Users\GreXLin85\Desktop\Projelerim\PC\xx\node_modules\express\lib\router\layer.js:95:5)
You should read about main and renderer processes in electron:
https://www.electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes
In main process you don't have global window variable: main process is node process, not a browser one.
And BrowserWindow class has no .selectPreviousTab() method - it's not an NSWindow and you are not writing native code in Swift. You should use electron/js documentation not native/Swift documentation ofr developing electron apps.
electron is a framework/platform for writing desktop applications in JS using node and chromium, it is not a native framework.

RNFS.upload gives unexpected end of stream error while I want to send files in the device to my server

I am Using react-native-fs for sending the files I picked by react-native-document-picker.
so I make a function and call it when all the required files are selected like the code below.
and when I call the function uploadImageReq() I got the following error on console
ERROR Error: unexpected end of stream
at Object.promiseMethodWrapper [as uploadFiles] (NativeModules.js:103)
at Object.uploadFiles (FS.common.js:594)
at uploadImageReq$ (AddScreen.js:73)
at tryCatch (runtime.js:45)
at Generator.invoke [as _invoke] (runtime.js:274)
at Generator.prototype.<computed> [as next] (runtime.js:97)
at tryCatch (runtime.js:45)
at invoke (runtime.js:135)
at runtime.js:170
at tryCallTwo (core.js:45)
the files is
[{name: "imageFile", filename: "IMGs.jpg", filepath: "/data/user/0/com.bookland/cacheNONE/1201418716", filetype: "image/jpeg"},{name: "imageFile", filename: "IMGs.jpg", filepath: "/data/user/0/com.bookland/cacheNONE/1201418716", filetype: "image/jpeg"}]
Thank you for your helps
You need to stringify all of your embeded items:
//Other code onTop
const {location, ...other} = payload;
form.append("location", JSON.stringify(location));
...
and i strongly Recommend you to use RNFetchBlob instead of Axios, dont forget to pass content type in to your header.
great coding