Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting error "SyntaxError Cannot use import statement outside a module"

Tags:

express

prisma

I am trying to use Prisma.js in my express app. but I am getting error on module import. I am not sure where am I going wrong.

    'use strict';
var sql = require('../connection.js');
import { PrismaClient } from '@prisma/client';
//const prisma = new PrismaClient()

class InvoiceService {
    constructor(){

    }

    getInvoices(body,query,user){
        
        return new Promise(function (resolve, reject) {
            
            resolve(query);
        });
    }
}

module.exports = {InvoiceService};
like image 607
Hussain Jawadwala Avatar asked Oct 30 '25 19:10

Hussain Jawadwala


1 Answers

Change the import to:

const { PrismaClient } = require('@prisma/client');

And it will work fine.

like image 191
Ryan Avatar answered Nov 02 '25 21:11

Ryan