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.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
Fabianssoncommented, Jun 4, 2021

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.

1reaction
aravindvnair99commented, May 5, 2021

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

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

node-pre-gyp info This Node instance does not support builds ...
Hi, I am using tensorflow in my Node.js rest API but it seems to give above notification . Idk if solving it will...
Read more >
This Node instance does not support builds for N-API version 6
When I try to run the project, the following message appears: node-pre-gyp info This ...
Read more >
node-pre-gyp - npm.io
A command line tool called node-pre-gyp that can install your package's C++ module from a binary. A variety of developer targeted commands for...
Read more >
Node-API | Node.js v19.3.0 Documentation
Node -API (formerly N-API) is an API for building native Addons. It is independent from the underlying JavaScript runtime (for example, V8) and...
Read more >
prebuild - The N-API Resource |
This is the specific solution offered by prebuild. Note that N-API support was added to prebuild in version 8.1.0. node-pre-gyp is an alternative...
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