Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeviceUUID is not a constructor #14

Open
rufrajput opened this issue Sep 7, 2021 · 11 comments
Open

DeviceUUID is not a constructor #14

rufrajput opened this issue Sep 7, 2021 · 11 comments

Comments

@rufrajput
Copy link

can someone help with this error? I am facing this error while running a desktop app build with js, svelte and go.

image

@johnpaulmedina
Copy link

That is because you are importing and setting it as a variable so you would technically need to write new DeviceUUID.DeviceUUID().get()

@denisvitez
Copy link

denisvitez commented May 26, 2022

I'm having the same issue with VueJS.

import { DeviceUUID } from "device-uuid";
let uuid = new DeviceUUID().get();

It works fine when running with npm run dev but fails when application is built with npm run build.

TypeError: deviceUuid.DeviceUUID is not a constructor

So if I do the following import:
import du from 'device-uuid'

And try to log the value of the object into the console
console.log("This is DU:", du);

I get the following:

npm run dev
This is DU: {DeviceUUID: ƒ}

npm run build
This is DU: {}

So basically as I can see nothing gets imported as du.

@yimingxie
Copy link

I'm having the same issue with VueJS.

import { DeviceUUID } from "device-uuid";
let uuid = new DeviceUUID().get();

It works fine when running with npm run dev but fails when application is built with npm run build.

TypeError: deviceUuid.DeviceUUID is not a constructor

So if I do the following import: import du from 'device-uuid'

And try to log the value of the object into the console console.log("This is DU:", du);

I get the following:

npm run dev This is DU: {DeviceUUID: ƒ}

npm run build This is DU: {}

So basically as I can see nothing gets imported as du.

Hey, man, I have the same problem. How did you solve it

@denisvitez
Copy link

I'm having the same issue with VueJS.

import { DeviceUUID } from "device-uuid";
let uuid = new DeviceUUID().get();

It works fine when running with npm run dev but fails when application is built with npm run build.
TypeError: deviceUuid.DeviceUUID is not a constructor
So if I do the following import: import du from 'device-uuid'
And try to log the value of the object into the console console.log("This is DU:", du);
I get the following:
npm run dev This is DU: {DeviceUUID: ƒ}
npm run build This is DU: {}
So basically as I can see nothing gets imported as du.

Hey, man, I have the same problem. How did you solve it

Hey,
I ended up dropping the library altogether and reworked the application by just using UUID - https://www.npmjs.com/package/vue-uuid. I then store this UUID in local storage and use it on subsequent session refreshes.

@devapurva
Copy link

This worked for me in react web app -

import DeviceUUID from "device-uuid";
var deviceUUID = new DeviceUUID.DeviceUUID().get();
console.log(deviceUUID)

@umrzoq-toshkentov
Copy link

So what's the solution on build?

@davidgs
Copy link

davidgs commented Apr 10, 2024

Make sure you are using import { DeviceUUID } from "device-uuid"; and not import DeviceUUID from "device-uuid"; as the latter will give you that error. DeviceUUID is, apparently, not the default export from device-uuid which causes this error.

@shifanpark
Copy link

So what's the solution on build?

@umrzoq-toshkentov Did you find any solution for this not working issue after build?

@umrzoq-toshkentov
Copy link

So what's the solution on build?

@umrzoq-toshkentov Did you find any solution for this not working issue after build?

not yet, seems to bee need to fix it.

@EdGaere
Copy link

EdGaere commented Jul 7, 2024

I had the same problem.

It seems a solution has been found on StackOverflow, which worked for me.

In your vite.config.js, add the following to the configuration and then build as normal.

  build: {
      commonjsOptions: { include: [] },
    },
    optimizeDeps: {
      disabled: false,
    },

@phil-w
Copy link

phil-w commented Jul 9, 2024

Yeah that optimizeDeps disabling now says in bright yellow when production building with Vite/ Rollup/whatever:

(!) Experimental optimizeDeps.disabled and deps pre-bundling during build were removed in Vite 5.1.
   Setting it to false now has no effect.
   Please remove optimizeDeps.disabled from your config.

And... it doesn't fix it. I think I need a different solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants