GoogleChromeLabs / web-gphoto2

Running gPhoto2 to control DSLR cameras over USB on the Web
https://web-gphoto2.rreverser.com/
GNU Lesser General Public License v2.1
101 stars 16 forks source link

How to use in NuxtJS? #10

Closed irvandikky closed 1 year ago

irvandikky commented 1 year ago

Hello how to use this library in NuxtJS? I'm using NuxtJS without typescript

"nuxt": "^2.15.8",

Always got error

ERROR  in ./node_modules/web-gphoto2/build/camera.js                                                                                   

Module parse failed: Unexpected character '#' (31:2)                                                                                  
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| let ModulePromise;
| export class Camera {
>   #queue = Promise.resolve();
|   #context = null;
|   static async showPicker() {
RReverser commented 1 year ago

Sounds like you need to upgrade Babel. It complains about private properties.

irvandikky commented 1 year ago

I'm using "@babel/runtime-corejs3": "^7.22.10",

Here is my package.json

"dependencies": {
        "@nuxtjs/auth": "^4.9.1",
        "@nuxtjs/axios": "^5.13.6",
        "@nuxtjs/pwa": "^3.3.5",
        "@tailwindcss/forms": "^0.5.4",
        "core-js": "3",
        "daisyui": "^3.5.1",
        "html5-qrcode": "^2.3.8",
        "nuxt": "^2.15.8",
        "tailwind-scrollbar": "^3.0.5",
        "vue": "^2.7.10",
        "vue-server-renderer": "^2.7.10",
        "vue-sweetalert2": "5.0.2",
        "vue-template-compiler": "^2.7.10",
        "vue-the-mask": "^0.11.1",
        "web-gphoto2": "^0.4.1",
        "yup": "^1.2.0"
    },
    "devDependencies": {
        "@babel/runtime-corejs3": "^7.22.10",
        "@nuxt/babel-preset-app": "^2.17.1",
        "@nuxt/image": "^0.7.1",
        "@nuxtjs/tailwindcss": "^5.3.3",
        "eslint-config-prettier": "^8.5.0",
        "prettier": "^2.7.1"
    }
irvandikky commented 1 year ago

I Got another error

ERROR  in ./node_modules/web-gphoto2/build/libapi.mjs                                                                                

Module parse failed: Unexpected token (3:25)                                                                                            
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| var Module = (() => {
>   var _scriptDir = import.meta.url;
|
|   return (

 @ ./node_modules/web-gphoto2/build/camera.js 21:0-45 61:22-32
RReverser commented 1 year ago

It's not runtime you need to upgrade, but babel-loader as that's where the error occurs - at Webpack compilation stage. It clearly can't recognise new JavaScript features.

Sorry, I'm not familiar with Nuxtjs and don't know how it's upgraded there. Either way, it's not a bug in this library.