Face-api.js: Angular New Project, including faceapi.js gives Built error

Created on 9 Jan 2020  路  6Comments  路  Source: justadudewhohacks/face-api.js

===========================
ERROR in node_modules/face-api.js/build/commonjs/NeuralNetwork.d.ts:8:9 - error TS1086: An accessor cannot be declared in an ambient context.

8 get params(): TNetParams | undefined;

I have installed face-api as npm i face-api.js
Version of Typescript- "typescript": "~3.5.3" for Angular/cli latest version is "@angular/cli": "~8.3.22",

I have added one line in the component.ts

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

Thanks a lot and best wishes..

Most helpful comment

Add face-api.js to the scripts array (angular.json)
"scripts": [ "./node_modules/face-api.js/dist/face-api.min.js" ]

Do not import faceapi into your component or service.
Just declare it after your imports like so:
declare var faceapi: any;

All 6 comments

As per the latest youtube video from web dev simplified and your tutorial we need to copy and paste the js from dist folder into angular assets folder and then run add npm i node-fetch..
Also in index.html ->
Also in the component.ts folder -> import * as faceapi from '../assets/face-api';

console.log(faceapi); confirms it has loaded. So please close this issue.

Same issue here. Can someone give a full example with Angular? I'm really lost

Add face-api.js to the scripts array (angular.json)
"scripts": [ "./node_modules/face-api.js/dist/face-api.min.js" ]

Do not import faceapi into your component or service.
Just declare it after your imports like so:
declare var faceapi: any;

@somogyi-develappers Thanks!, it worked, I was able to access all the face-api functionality from the given changes. But I wonder why the import thing didn't worked, because for tensorflow.js it works.
Hint for others: After making given changes try restarting the server LiveDemo and used AngularCode

I was getting same error. Fixed it by setting "skipLibCheck" : true in tsconfig.json under the "compilerOptions"

@somogyi-develappers Thanks!, it worked, I was able to access all the face-api functionality from the given changes. But I wonder why the import thing didn't worked, because for tensorflow.js it works.
Hint for others: After making given changes try restarting the server LiveDemo and used AngularCode

@Im-Himanshu Thanks for your reference. Can you pls share how shall i upload a image and detect face or match it with other images

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LeonardoDB picture LeonardoDB  路  6Comments

luisdemarchi picture luisdemarchi  路  3Comments

swapanil picture swapanil  路  5Comments

liyinghao666 picture liyinghao666  路  5Comments

logypaser picture logypaser  路  3Comments