question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tsc compilation error

See original GitHub issue

Hi All,

Just got an error on running node program:

yarn run v1.16.0
$ D:\Github\Minazuki\node\node_modules\.bin\ts-node detection.ts ../images/pos1.jpg
cpu backend was already registered. Reusing existing backend factory.
Platform node has already been set. Overwriting the platform with [object Object].
node-pre-gyp info This Node instance does not support builds for N-API version 4
node-pre-gyp info This Node instance does not support builds for N-API version 4
2019-08-08 11:12:39.517916: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

D:\Github\Minazuki\node\node_modules\ts-node\src\index.ts:245
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
utils/faceDetection.ts:19:10 - error TS2367: This condition will always return 'false' since the types 'NeuralNetwork<any>' and 'SsdMobilenetv1' have no overlap.

19   return net === faceapi.nets.ssdMobilenetv1
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
utils/faceDetection.ts:21:7 - error TS2367: This condition will always return 'false' since the types 'NeuralNetwork<any>' and 'TinyFaceDetector' have no overlap.

21     : net === faceapi.nets.tinyFaceDetector
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
utils/faceDetection.ts:26:60 - error TS2345: Argument of type 'TinyFaceDetector' is not assignable to parameter of type 'NeuralNetwork<any>'.
  Types of property 'extractParamsFromWeigthMap' are incompatible.
    Type '(weightMap: NamedTensorMap) => { params: TinyYolov2NetParams; paramMappings: ParamMapping[]; }' is not assignable to type '(weightMap: NamedTensorMap) => { params: any; paramMappings: ParamMapping[]; }'.
      Types of parameters 'weightMap' and 'weightMap' are incompatible.
        Type 'import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/tensor_types").NamedTensorMap' is not assignable to type 'import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/tensor_types").NamedTensorMap'.
          Index signatures are incompatible.
            Type 'import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/types").Rank>'
is not assignable to type 'import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/types").Rank>'.
              Types of property 'flatten' are incompatible.
                Type '() => import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R1>' is not assignable to type '() => import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R1>'.
                  Type 'import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R1>' is not assignable to type 'import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R1>'.
                    Types of property 'asScalar' are incompatible.
                      Type '() => import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R0>' is not assignable to type '() => import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R0>'.
                        Type 'import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R0>' is not assignable to type 'import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R0>'.
                          Types of property 'as2D' are incompatible.
                            Type '(rows: number, columns: number) => import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R2>' is not assignable to type '(rows: number, columns: number) => import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R2>'.
                              Type 'import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R2>' is not assignable to type 'import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R2>'.
                                Types of property 'asType' are incompatible.
                                  Type '<T extends import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R2>>(this: T, dtype: "string" | ... 3 more ... | "complex64") => T' is not assignable to type '<T extends import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R2>>(this: T, dtype: "string" | ... 3 more ... | "complex64") => T'.
                                    The 'this' types of each signature are incompatible.
                                      Type 'T' is not assignable to type 'Tensor<Rank.R2>'.
                                        Property 'bytes' is missing in type 'import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/face-api.js/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R2>' but required in type 'import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/tensor").Tensor<import("D:/Github/Minazuki/node/node_modules/@tensorflow/tfjs-core/dist/types").Rank.R2>'.

26 export const faceDetectionOptions = getFaceDetectorOptions(faceDetectionNet)
                                                              ~~~~~~~~~~~~~~~~

  node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:374:5
    374     bytes(): Promise<Uint8Array[] | Uint8Array>;
            ~~~~~
    'bytes' is declared here.

    at createTSError (D:\Github\Minazuki\node\node_modules\ts-node\src\index.ts:245:12)
    at reportTSError (D:\Github\Minazuki\node\node_modules\ts-node\src\index.ts:249:19)
    at getOutput (D:\Github\Minazuki\node\node_modules\ts-node\src\index.ts:362:34)
    at Object.compile (D:\Github\Minazuki\node\node_modules\ts-node\src\index.ts:395:32)
    at Module.m._compile (D:\Github\Minazuki\node\node_modules\ts-node\src\index.ts:473:43)
    at Module._extensions..js (module.js:663:10)
    at Object.require.extensions.(anonymous function) [as .ts] (D:\Github\Minazuki\node\node_modules\ts-node\src\index.ts:476:12)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The root cause of this error maybe because I just upgrade typescript from 3.5.2 to 3.5.3 and @tensorflow/tfjs-node from 1.2.3 to 1.2.7 Anyone here have this error and solutions? Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
russellwmycommented, Aug 15, 2019

I had the same error. It is mainly the @tensorflow/tfjs-node version 1.2.7 issues. I think face-api.js dependent on the @tensorflow/tfjs-node version 1.2.2 which you can read the package.json in root of this repos. You can uninstall @tensorflow/tfjs-node and reinstall face-api.js then it will be fine.

0reactions
xellDartcommented, Aug 20, 2019

{ "name": "rem_services", "version": "0.0.1", "description": "REM REST Services", "main": "dist/server.js", "scripts": { "build": "tsc", "dev": "ts-node lib/server.ts", "start": "nodemon ./dist/server.js", "prod": "npm run build && npm run start" }, "author": "xperiafan13", "license": "ISC", "dependencies": { "@tensorflow/tfjs-node": "^1.0.2", "@types/express": "^4.17.0", "@types/node": "^12.7.1", "awesome-qr": "^1.2.0", "axios": "^0.19.0", "ba64": "^3.0.9", "body-parser": "^1.19.0", "canvas": "^2.5.0", "cloudinary": "^1.14.0", "dateformat": "latest", "ethers": "^4.0.20", "express": "^4.17.1", "face-api.js": "^0.19.0", "file-encryptor": "^0.1.1", "firebase-admin": "latest", "http": "0.0.0", "image-hash": "^3.3.9", "int-encoder": "^1.1.1", "inversify": "^5.0.1", "inversify-express-utils": "^6.3.2", "jsonpack": "^1.1.5", "jsonwebtoken": "^8.5.1", "lodash": "latest", "mongodb": "latest", "mongoose": "^5.6.9", "mustache-express": "^1.2.8", "node-gd": "^1.6.0", "node-schedule": "^1.3.2", "nodemailer": "latest", "oidc-provider": "^5.5.6", "p-iteration": "^1.1.8", "rand-token": "latest", "reflect-metadata": "^0.1.13", "socket.io": "^2.2.0", "speakeasy": "^2.0.0", "ts-node": "^8.3.0", "typescript": "^3.5.3", "web3": "^1.2.1", "web3-eth-accounts": "^1.2.1" } }

{ "compilerOptions": { "module": "commonjs", "moduleResolution": "node", "experimentalDecorators": true, "skipLibCheck": true, "pretty": true, "sourceMap": true, "resolveJsonModule": true, "noImplicitAny": false, "allowJs": true, "declaration": false, "target": "es6", "outDir": "./dist", "baseUrl": "./lib" }, "include": [ "lib/**/*.ts", "lib/**/*.js" ], "exclude": [ "node_modules" ] }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does the tsc command not show compiling errors when ...
Due to having strict:true in my tsconfig.json file I get a nice error when I run tsc from the root folder. The error...
Read more >
Avoid TypeScript errors in your project by using the TypeScript ...
Assuming you are new to TypeScript, tsc is The TypeScript Compiler. It is a tool responsible for turning your TypeScript (which is a...
Read more >
Detect JavaScript errors during compile time using TypeScript ...
During compile-time TypeScript can emit errors to a terminal, and does not allow compiling of a code at all.
Read more >
Documentation - tsc CLI Options - TypeScript
Flag Type Default ‑‑allowJs boolean false ‑‑allowUmdGlobalAccess boolean false ‑‑allowUnreachableCode boolean
Read more >
Not reporting tsc compile errors correctly in the problems view
Observe that the "assignment to readonly field" error is shown. Also, it looks like other errors, such as real syntax errors, are only...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found