tfjs: node-pre-gyp info This Node instance does not support builds for N-API version 8

I am trying to use TensorFlow with Firebase Cloud Functions. I’m on Node.js v14.16.0 which should be Node-API v7.

And I get this when starting the server:

$ firebase serve
!  D:\folder_name\functions\node_modules\@tensorflow\tfjs-automl\dist\index.js:18
export { ImageClassificationModel, loadImageClassification } from './img_classification';
^^^^^^

SyntaxError: Unexpected token 'export'
    at wrapSafe (internal/modules/cjs/loader.js:979:16)
    at Module._compile (internal/modules/cjs/loader.js:1027:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (D:\folder_name\functions\index.js:14:11)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
!  We were unable to load your functions code. (see above)
$ head -n 14 index.js
const functions = require("firebase-functions"),
        express = require("express"),
        app = express(),
        admin = require("firebase-admin"),
        cookieParser = require("cookie-parser"),
        Busboy = require("busboy"),
        path = require("path"),
        os = require("os"),
        fs = require("fs"),
        vader = require("vader-sentiment"),
        morgan = require("morgan"),
        axios = require("axios"),
        tfnode = require("@tensorflow/tfjs-node"),
        automl = require("@tensorflow/tfjs-automl");
$ node
Welcome to Node.js v14.16.0.
Type ".help" for more information.
> console.log(process.versions.napi)
7
undefined
> .exit
$ cat package.json
"dependencies": {
                "@tensorflow/tfjs-automl": "^1.1.0",
                "@tensorflow/tfjs-converter": "^3.3.0",
                "@tensorflow/tfjs-core": "^3.3.0",
                "@tensorflow/tfjs-node": "^3.6.1",
        },

MCVE available at: https://github.com/aravindvnair99/TFJS-Issue-5017

I’ve set up a GitHub Actions workflow to reproduce the issue on multiple OS and Node.js versions. Results are available here: https://github.com/aravindvnair99/TFJS-Issue-5017/actions

It’s failing in all cases. Workflow configuration: https://github.com/aravindvnair99/TFJS-Issue-5017/blob/main/.github/workflows/node.js.yml

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (12 by maintainers)

Most upvoted comments

To be clear I did not manage to install the newest tfjs-node on any Node Version. I tested on Node: 10x, 12x, 14x and even 16x. Would have to look up which version exactly. I tried on Windows, Ubuntu and WSL(Ubuntu). Some combinations will not install at all and also manual building does not work reliably. I’m genuinly surprised not more people are having this problem. I really don’t know what else I could try. Maybe someone can specify a exact working combination of Node-Version, OS and tfjs-node version so I could try this.

@pyu10055 Can confirm updating to @tensorflow/tfjs-automl v1.2.0 has resolved the issue.

Fixed in https://github.com/tensorflow/tfjs/pull/5024