trying to import 'uuid' in the user model as
import { v1 as uuidv1 } from "uuid";
But, I don't know why it gives syntaxError like this import { v1 as uuidv1 } from "uuid"; ^^^^^^SyntaxError: Cannot use import statement outside a module
trying to import 'uuid' in the user model as
import { v1 as uuidv1 } from "uuid";
But, I don't know why it gives syntaxError like this import { v1 as uuidv1 } from "uuid"; ^^^^^^SyntaxError: Cannot use import statement outside a module
-I am assuming that you have used export.modules in your uuid.js.
Also i am assuming that uuid.js file is present in the same directory as the one in which your are importing the function.
Now if you want to use the functions present in uuid.js to another file then you can use require() to import the function in your other js file. Try using below syntax to import the function.
const v1=require(./uuid); Now you can use v1.uuidv1(); in your js file.
However if you want to specifically use the syntax which you have used then you can refer the link which have been provided by Daniel A White