Search code examples
javascriptnode.jsface-apifacial-identification

Uncaught SyntaxError: Unexpected identifier on face-api import


I'm trying to make a simple demo application to use face-api. Line 2 of my code is throwing this error when I attempt to import the face-api.min.js file.

I've tried reformatting the import but I haven't been able to get it working.

//Importing Face Detection API
import faceapi from "./face-api.min.js";

Uncaught SyntaxError: Unexpected identifier


Solution

  • As the package documentation says, the correct way to import it is

    import * as faceapi from 'face-api.js';
    

    EDIT: For usage in Node.js with CommonJS imports you can do:

    const faceapi = require('face-api.js');